Macro with message boxes

JanetS

New member
Local time
Today, 14:21
Joined
Dec 14, 2012
Messages
9
I have a form with a button which calls a macro to open a query that performs a single record append into a table. The table has a field that is indexed and does not allow duplicates.
I want to add the following to the macro: Set warnings off to eliminate all the message boxes that pop up--1 to inform that an action is being taken, 1 to inform that 1 record is being appended and 1 with very confusing text to inform the action cannot be taken if the record is already in the table. TMI and potentially confusing.
After setting warnings off I want to provide a message box that informs 'Item is Already in table' if the record exists in the table or a message box that informs '1 record has been added' if a record does not exist in the table.
I know this can't be all that difficult. I just can't get the sequencing right.
Help, please:banghead:
 
I am not sure what exactly you are doing but some thoughts:

Before your append query macro and set warnings OFF, another macro MsgBox stating "The data is already in the table" and then stop macro if a condition meets. The condition may be written with DLookUp comparing the append field data to table data. You can display append data on the form in a field either already existing or a hidden field.

If condition does not meet, macro advances to set warnings off. After set warnings ON you can display a msg that "Data successfully appended."

Does it sound doable?

best regards.
 

Users who are viewing this thread

Back
Top Bottom