Yes to continue

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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
 
Back
Top