Prevent main form from closing when field not updated in subform

bgotis

Registered User.
Local time
Today, 03:59
Joined
Feb 7, 2001
Messages
12
In my subform, I want to required entry in the END_DATE field if the field Status ="Complete"

So far the code will continue to take the user back to the END_DATE field and prompt for a date as long as the Status is complete --- *except* if the user just closes the form. They'll get the error message three or four times, but eventually can close the form without entering the required information.

How do I keep the main form from closing when the required data is not entered on the subform?

Thanks in advance.
 
have a boolean called required

if "Me.requiredfield.text" = "" then
required = true
End if

on the click event of button to close the form put the following code in

If required = true then
msgBox("required field is empty")
Else
'code to close the button
End if




[This message has been edited by Anauz (edited 02-22-2001).]
 
In what part of the class module do I name the boolean?
 
You need to put the code in the BEFOREUpdate event of the form. From your description, it sounds like you have placed it in the AFTERUpdate event.

If -your edit goes here- Then
Else
MsgBox "End Date is required, update is being cancelled", vbOKOnly
Cancel = True
Me.END_DATE.SetFocus = True
End If
 

Users who are viewing this thread

Back
Top Bottom