E
Emma Aumack
Hi All,
I have a subform "Frm_Exp_Detail" (which is one of several detail forms)
that is opened via a select case statement on the main form "Frm_Exp". both
of these forms are based on the same table. I didn't do a seaprate details
table because there is only 1 detail for each record. The reason for the
details form is that my users insist on having the main form in a datasheet
view and the detail would make it way to busy, hence, the subform.
On each subform are 3 checkboxes, two of the checkboxes are mutually
exclusive and the other is supposed to be checked once all the detail is
completed.
I have a function, called from the BeforeUpdate event on the subform, that
fires if the user tries to close the subform without checking one of the
first 2 checkboxes as follows:
Function Snd_Ltr_Checked(CheckBox1 As CheckBox, CheckBox2 As CheckBox) As
Boolean
' Pass the checkboxes themselves to this function. So they can be used in
any form.
' This function will return True if only one checkbox is checked, and False
if neither
' or both are checked.
Dim boolChecked As Boolean
boolChecked = Nz(CheckBox1, False) Xor Nz(CheckBox2, False)
If Not boolChecked Then
msgbox "You must check one or the other of " &
CheckBox1.Controls(0).Caption & " or " & CheckBox2.Controls(0).Caption
End If
Snd_Ltr_Checked = boolChecked
End Function
My problem is that when the msgbox appears and "OK" is clicked, the subform
closes with the msgbox and I am taken back to the main form. I should be
taken back to the subform so that one of the check boxes can be checked.
I have tried to use cancel in the subform as follows:
cancel = Snd_Ltr_Checked(snd_ltr, dn_snd_ltr)
and have tried
docmd.cancelevent
in the close event, with no luck.
HELP!!!
I have a subform "Frm_Exp_Detail" (which is one of several detail forms)
that is opened via a select case statement on the main form "Frm_Exp". both
of these forms are based on the same table. I didn't do a seaprate details
table because there is only 1 detail for each record. The reason for the
details form is that my users insist on having the main form in a datasheet
view and the detail would make it way to busy, hence, the subform.
On each subform are 3 checkboxes, two of the checkboxes are mutually
exclusive and the other is supposed to be checked once all the detail is
completed.
I have a function, called from the BeforeUpdate event on the subform, that
fires if the user tries to close the subform without checking one of the
first 2 checkboxes as follows:
Function Snd_Ltr_Checked(CheckBox1 As CheckBox, CheckBox2 As CheckBox) As
Boolean
' Pass the checkboxes themselves to this function. So they can be used in
any form.
' This function will return True if only one checkbox is checked, and False
if neither
' or both are checked.
Dim boolChecked As Boolean
boolChecked = Nz(CheckBox1, False) Xor Nz(CheckBox2, False)
If Not boolChecked Then
msgbox "You must check one or the other of " &
CheckBox1.Controls(0).Caption & " or " & CheckBox2.Controls(0).Caption
End If
Snd_Ltr_Checked = boolChecked
End Function
My problem is that when the msgbox appears and "OK" is clicked, the subform
closes with the msgbox and I am taken back to the main form. I should be
taken back to the subform so that one of the check boxes can be checked.
I have tried to use cancel in the subform as follows:
cancel = Snd_Ltr_Checked(snd_ltr, dn_snd_ltr)
and have tried
docmd.cancelevent
in the close event, with no luck.
HELP!!!