Yet another Validation teaser (for me anyway)

Carl_R

Registered User.
Local time
Today, 14:20
Joined
Aug 16, 2002
Messages
82
I have a form which is opened in ADD mode.

There are three fields (ImpDate, Group, Crit) which the users must complete before they can close the form.

We are running with Validation rule set to 'Is Not Null' and having some Validation text prompt the users.

Unfortuantely, this is no longer good enough as the users may start a record and then decide that they don't want to continue (they have no delete capability).

What I'm after is a way to check these three fields for data.

If they contain data, great, the user can close the form.
If only one or two of the fields contain data and the user tries to close the form, I want them to receive a YES/NO msgbox informing them if they want to continue and that if they click NO the record will be deleted (and the form will close). If they click YES, they can continue to complete the change.

Stumped :confused:
 
On the form unload event add the following code...


if isnull(me!field1) or me!field1 = "" then
cancel = 1
end if

if isnull(me!field2) or me!field2 = "" then
cancel = 1
end if

if isnull(me!field3) or me!field3 = "" then
cancel = 1
end if

<<<END CODE>>>

Remember to change Field1, 2 3 to the name of the controls on your form.

Having Fun Yet?
 
Hehe, beginning to have fun...

Tried that but I do have a Close button running a DoCmd.Close of the form. This has a conflict: The error is something like I am trying to issue a DoCmd and Cancel in a dialogue at the same time.

Oh, all window close 'x' buttons have been disabled so the only way to close any forms is via a custom close button.
 
In that case do this...


if isnull(me!field1) or me!field1 = "" then
cancel = 1
end if

if isnull(me!field2) or me!field2 = "" then
cancel = 1
end if

if isnull(me!field3) or me!field3 = "" then
cancel = 1
end if

If cancel = 1 then
msgbox "Need more data"
ELSE
docmd.close
end if

Now we'r cookin'
 

Users who are viewing this thread

Back
Top Bottom