Before up date (Validation)

Vav

Registered User.
Local time
Today, 06:39
Joined
Aug 29, 2002
Messages
36
Hello,

(A few days ago I asked this question but the suggestion I got back did not work)

I want to validate a form to make sure all the required information is filled out by the user before going to another record or exiting the form all together.

The suggestion I received was to write code in the before update.

I tried that suggestion but either I did it wrong or it didn't work.

I am alittle unsure of where I am meant to write the code. In the before update of the text box or in the form?

If someone wouldn't mind helping me I could really use the help.

And if it is not to much to ask would you be able to write the code for me.

One of the text boxes that I want to validate is "Order #". The name of the text box is txtOrderId.

I want to prompt the user with a msgbox saying "You must enter an Order number before leaving this form"

Then set focus back to the txtOrderId

***************************************

Here's what I wrote

Private Sub Form_BeforeUpdate(Cancel As Integer)

If txtOrderId = Null Then

MsgBox "You Must enter a valid Order Number"

End If

txtOrderId.SetFocus
End Sub

****************************************

Am I even going in the right direction?

Thanks,

Peter Vav
 
Last edited:
Try This :

On the ONGOTFOCUS property of the next field in the form put the following code :

If IsNull(me.txtOrderId) Then
Msgbox "You Must Enter a Order Number"
End If

This basically says that when someone navigates away from the field that it tells them and they have not entered this data.

This assumes you have your fields in tab order.

Alternatively you could set the table field to required = YES


Regards

Andy
 

Users who are viewing this thread

Back
Top Bottom