S
Shane S via AccessMonster.com
I have read a number of threads about validating required fields in the forms
BeforeUpdate event so I'm trying to accomplish what has been recommended, but
having one problem. The code below will trap whether the LastName control has
been filled in or not and will display the messages correctly but if I choose
"Yes" as a choice when asked if I know the name, then I expect to have the
focus set to the LastName control but instead the form goes again a closes.
What am I doing wrong that I can not get the form to not close and get the
focus set to the LastName control?
If Trim(Nz(Me.LastName, 0)) = 0 Then
If Eval("Msgbox('Last Name Field Has Been Left Blank@Last Name field must
been filled out in order to " & _
"save record@Do you know the Last Name?@@',4,'Amigo Message System')") = vbNo
Then
Eval ("Msgbox('I can not save this record at this time!@I can not save a
record on a P.T. and not " & _
"know their last name. Sorry!!!@@',0,'Amigo Message System')")
Cancel = True
Else
Me.LastName.SetFocus
Cancel = True
Exit Sub
End If
End If
TIA,
Shane
BeforeUpdate event so I'm trying to accomplish what has been recommended, but
having one problem. The code below will trap whether the LastName control has
been filled in or not and will display the messages correctly but if I choose
"Yes" as a choice when asked if I know the name, then I expect to have the
focus set to the LastName control but instead the form goes again a closes.
What am I doing wrong that I can not get the form to not close and get the
focus set to the LastName control?
If Trim(Nz(Me.LastName, 0)) = 0 Then
If Eval("Msgbox('Last Name Field Has Been Left Blank@Last Name field must
been filled out in order to " & _
"save record@Do you know the Last Name?@@',4,'Amigo Message System')") = vbNo
Then
Eval ("Msgbox('I can not save this record at this time!@I can not save a
record on a P.T. and not " & _
"know their last name. Sorry!!!@@',0,'Amigo Message System')")
Cancel = True
Else
Me.LastName.SetFocus
Cancel = True
Exit Sub
End If
End If
TIA,
Shane