Macro to create a message box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm not sure if this is possible but I'll ask anyway

I want to create a macro to create a message box. I need the message box to appear on the form as a warning when a record inputted into a field on the form equals a record on an existing query

ie. upon inputting an account number on a form that is present on an existing query, I want the message box to appear

I can set up the message box, but can't figure out how to set the condition/expression to look to the existing query to see if the inputted record on the form exists on the query.
 
The database engine can take care of this for you. In this case, all you
need is a unique index on the field. Now, if your user enters an
existing value in the form control (that is bound to the field in the
table!) error 3022 occurs (you can catch that in the Error event of the
form if you want to present some choice to the user)
 
Thanks Bas,

The field in question will have duplicate values. I want the macro to read the form control and compare it to a field in an existing query, to see if the value the user entered on the form control matches a record on the query....

I need to know how to build the expression to look for this

Thanks for your help.
 
Do you say 'macro' on purpose? Macros don't take parameters and do not
pass values, I have long switched to VBA.

The function DLookup() will get you out anyway, see Help.
 
It is good to see you back. You were certainly missed, and your return is
most welcome. ;-))

Jan :)
A very appreciative helpee.

Bas Cost Budde said:
Do you say 'macro' on purpose? Macros don't take parameters and do not
pass values, I have long switched to VBA.

The function DLookup() will get you out anyway, see Help.
read the form control and compare it to a field in an existing query, to see
if the value the user entered on the form control matches a record on the
query....
 
Back
Top