Validation rules

Toolpusher

Registered User.
Local time
Today, 02:22
Joined
May 29, 2007
Messages
53
Hi

I have a form, two of the fields are Comment which is a text box and Update which is a combo box with a list of names. I am trying to prevent someone selecting his name as having updated the record but leaving the Comment field blank. Have tried validation rules on the Combo box but think I need some code to make this happen. Any help appreciated .

TP
 
don't use validation rules.

I assume you are in a form.


use the BEFOREUPDATE event of the form for validation, and try this sort of thing.

cancel = true is the thing. it prevents the record save taking place.


......
Code:
'test the comments field
if nz(commentfield,"") = "" then
    msgbox("please enter a comment")
    cancel=true 'prevent the update
    comment.setfocus  'force the user to the comment field
    exit sub  'end the sub now
end if
 
... other code here
 
Hi

thanks for the prompt reply. I get an error in the debugger at Comment.SetFocus where .SetFocus is highlighted take it this should move the cursor back to the comment field?

regards

TP
 

Users who are viewing this thread

Back
Top Bottom