'Before Update' Code Not Working

lhooker

Registered User.
Local time
Today, 13:31
Joined
Dec 30, 2005
Messages
423
Can anyone tell me why the below code works in my 'Event Procedure' code behind a 'Button' and not when I move the code to 'Event Procedure' for 'Before Update' ? When I tab pass an empty (blank) text boxes, it does not produce the pop-up error message. The code works with the 'Button' 'Event Procedure'.

If IsNull([First_Name]) Then
MsgBox "Please enter your first name.", , " Missing First Name"
SurveyError = "On"
[First_Name].SetFocus
GoTo Bottom
End If
 
Form before update or control before update? I'm assuming control before update and if you are just tabbing past the control it is not updating and the event is not firing. you should do your validation in the forms before update.
 
Moke123,

Are you saying I should continue my validation process in the 'Button' 'Event Procedure' ?
 
Are you saying I should continue my validation process in the 'Button' 'Event Procedure' ?

No...

...you should do your validation in the forms before update.

If the Control is Null (empty) you'll need to cancel the Record's being saved, and Canceling the event isn't available in the OnClick event of a Command Button, but it is in the Form_BeforeUpdate event.

Also, when validating for Null (empty) Controls, you never use Events connected to the Control in question (i.e TextboxName_BeforeUpdate, TextboxName_AfterUpdate, etc) because all the OP has to do to beat the validation is to simply not enter the Control!

Linq ;0)>
 
Last edited:
Can anyone tell me why the below code works in my 'Event Procedure' code behind a 'Button' and not when I move the code to 'Event Procedure' for 'Before Update' ? When I tab pass an empty (blank) text boxes, it does not produce the pop-up error message. The code works with the 'Button' 'Event Procedure'.

If IsNull([First_Name]) Then
MsgBox "Please enter your first name.", , "Missing First Name"
SurveyError = "On"
[First_Name].SetFocus
GoTo Bottom
End If

I am with missinglinq on this. Use the form's BeforeUpdate event and cancel if the text is not entered in the individual controls. Change the code to the following:
Code:
If Nz([First_Name])= "" Then   ' catches Null and zero length string
       MsgBox "Please enter your first name.", , "        Missing First Name"
        Cancel = True
       [First_Name].SetFocus
       Exit Sub
    End If

This should work with no issues.

Best,
Jiri
 

Users who are viewing this thread

Back
Top Bottom