Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validating data in form using macro to run beforeupdate 1

Status
Not open for further replies.

triffe

Technical User
Jun 21, 2001
20
0
0
US
I've created a macro to check a value entered on a form and set the form's properties to run this macro Before Updating. The 2 actions of the macro are Msgbox and CancelEvent. The message I created does cause a text box to appear, but if you correct the value so the message box goes away or enter in a valid entry to begin with, you can't advance to a new record. I put the cancelevent action in so that the record would not update the table with the incorrect value in it.

What can I do to tell it that if the value is correct, update the table and bring up a new record on my form?

triffe
 
If you use VBA code you can do more.

So you have a pop up and you want to check its value.

dim retval as variant
retval= inputbox ("Prompt", "Title", DefaultValue)

If retval = Something then
'do something
Else
' Do something different
End if
DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Why not use the controls Validation Rule to do this instead of coding it yourself?

Joe Miller
joe.miller@flotech.net
 
Doug,

Thanks for the advice. Unfortunately, I am not well versed in VBA code which is why I was trying to use the macros to begin with.

Your suggestion will work except I don't know how to tell it to add the record to the underlying table if the value is correct.

I'd appreciate any other help you could give me on how to do this.

triffe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top