Prevent main form from closing when field not updated in subform (1 Viewer)

bgotis

Registered User.
Local time
Today, 09:04
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.
 

Anauz

Registered User.
Local time
Today, 09:04
Joined
Nov 14, 2000
Messages
81
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).]
 

bgotis

Registered User.
Local time
Today, 09:04
Joined
Feb 7, 2001
Messages
12
In what part of the class module do I name the boolean?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 04:04
Joined
Feb 19, 2002
Messages
43,445
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

Top Bottom