Stop closing form (1 Viewer)

momoko

Registered User.
Local time
Today, 19:38
Joined
Oct 7, 2001
Messages
41
Hi,
How can I stop user from closing the form if the mantory fields are not filled up? I try using gotocontrol but it is not working.
 

ksj

New member
Local time
Today, 11:38
Joined
Jul 26, 2007
Messages
9
On the unload event of the form, Do a

me.MandatoryControl.SetFocus
If IsNull(me.MandatoryControl) = True or me.MandatoryControl = "" Then ' or whatever your defaults would be...
MsgBox "You must put a value in field X.", vbOKOnly, "Data Required"
DoCmd.CancelEvent
End If

It will stop the form from closing, but keep in mind the record has already been saved, and if the user has changed their mind about whatever it is they are doing, it will drive them insane to not be able to exit the form without inputting the data.
 
Last edited:

Users who are viewing this thread

Top Bottom