Yes to continue

G

Guest

i need to create a conditional macro that alerts you that
you are about to enter a duplicated number and to click
yes to continue.
 
T

tina

the following solution calls the first macro to check for dups, and if
they're found, calls the second macro to ask the "Yes or No" question. call
the first macro from the control's BeforeUpdate event.

MacroName: CheckForDups
<use the following condition if MyFieldName is a numeric data type.>
Condition: DCount("[MyFieldName]", "MyTableName", "[MyFieldName] = " &
MyControlName) > 0
<if MyFieldName is a text data type, use the condition below *instead of*
the one above.>
Condition: DCount("[MyFieldName]", "MyTableName", "[MyFieldName] = '" &
MyControlName & "'") > 0
Action: RunMacro
MacroName: AskQuestion

MacroName: AskQuestion
Condition: MsgBox("This is a duplicate value. Do you want to enter
it?",4)=7
Action: CancelEvent

hth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top