G
Guest
Using WinXP and Access2K2
On a form I have this code to check if a control has data and checkboxes
have been checked. The form is based on a Query of the underlying Table so I
can alphabetize the names on the form level.
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo ProcError
'Checks to see if a date has been entered and if a Category has been checked
If IsNull(Me.dteEnterDate) Then
MsgBox "Please Enter A Date."
Me.dteEnterDate.SetFocus
ElseIf Me.ysnClient = False And Me.ysnDonor = False And Me.ysnCharity =
False And Me.ysnVolunteer = False Then
MsgBox "You must select at least one Entity Category."
Me.dteEnterDate.SetFocus
Cancel = True
End If
ExitProc:
Exit Sub
ProcError:
MsgBox "error" & Err.Number & ": " & Err.Description
Resume ExitProc
End Sub
Almost everything works fine, except when attempting to leave the record and
no checkboxes have been checked. The 1st message box: "You must select at
least one Entity Category." I click on "OK" and then the 2nd message box:
"You entered an expression that has an invalid reference to the property |."
I click on "OK" and focus goes to the control; 'dteEnterDate' like it is
supposed to do. I can check any of the above check boxes and 'refresh' and
everything is fine.
I'd like to be able to write the code correctly to not have the 2nd message
box appear.
As always, suggestions appreciated.
On a form I have this code to check if a control has data and checkboxes
have been checked. The form is based on a Query of the underlying Table so I
can alphabetize the names on the form level.
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo ProcError
'Checks to see if a date has been entered and if a Category has been checked
If IsNull(Me.dteEnterDate) Then
MsgBox "Please Enter A Date."
Me.dteEnterDate.SetFocus
ElseIf Me.ysnClient = False And Me.ysnDonor = False And Me.ysnCharity =
False And Me.ysnVolunteer = False Then
MsgBox "You must select at least one Entity Category."
Me.dteEnterDate.SetFocus
Cancel = True
End If
ExitProc:
Exit Sub
ProcError:
MsgBox "error" & Err.Number & ": " & Err.Description
Resume ExitProc
End Sub
Almost everything works fine, except when attempting to leave the record and
no checkboxes have been checked. The 1st message box: "You must select at
least one Entity Category." I click on "OK" and then the 2nd message box:
"You entered an expression that has an invalid reference to the property |."
I click on "OK" and focus goes to the control; 'dteEnterDate' like it is
supposed to do. I can check any of the above check boxes and 'refresh' and
everything is fine.
I'd like to be able to write the code correctly to not have the 2nd message
box appear.
As always, suggestions appreciated.