I have a data entry form (Access02) with five pieces of data and they all need to be required. They cannot be required at the table level because other entries require a differnt set of values. I wrote the following code:
If Len([LaborDate]) > 0 And [JobID]) <> 0 And Len([EmployeeID]) > 0 And Len([ProdID]) > 0 And Len([Quantity]) > 0 Then
GoTo GoOn
Else
DoCmd.CancelEvent
MsgBox "Please complete all fields"
DoCmd.CancelEvent
End If
GoOn:
This works fine if the user tries to save the current record but if the user closes the form, the message box comes up but it still closes the form after clicking OK.
I thought the CancelEvent would cancel the close but it does not. The second CancelEvent was added because one did not work.
Any thoughts on how this should be done?
Thanks,
alr
_____________________________________
If a large part of intelligence is the ability to generalize, it is ironic that a large part of what we call wisdom is the ability not to generalize.
If Len([LaborDate]) > 0 And [JobID]) <> 0 And Len([EmployeeID]) > 0 And Len([ProdID]) > 0 And Len([Quantity]) > 0 Then
GoTo GoOn
Else
DoCmd.CancelEvent
MsgBox "Please complete all fields"
DoCmd.CancelEvent
End If
GoOn:
This works fine if the user tries to save the current record but if the user closes the form, the message box comes up but it still closes the form after clicking OK.
I thought the CancelEvent would cancel the close but it does not. The second CancelEvent was added because one did not work.
Any thoughts on how this should be done?
Thanks,
alr
_____________________________________
If a large part of intelligence is the ability to generalize, it is ironic that a large part of what we call wisdom is the ability not to generalize.