Help with Macro msgbox

  • Thread starter Thread starter JT
  • Start date Start date
J

JT

I am using a Switchboard menu to run a macro that will initialize my
database. I am trying to add a MSGBOX that will give the user the
option to back out when the answer "NO" is selected and return back to
Switchboard menu and if "Yes" continue through the macro.I even tried
to call a module and depending on the resolution either close macro
and retun or continue but I can't make it work. Anyone help me with
this?
 
Code for your module:

msg = "Main message text"
ttl = "Message box title"
chk = MsgBox msg, vbYesNo, ttl
if chk = vbNo then Exit Function
'code to execute iof yes is pressed

HTH,
Nikos
 
JT,

Put the MsgBox function in the macro Condition like this...

Condition: MsgBox("Continue?",36)=7
Action: StopMacro
 
Parton me for being so stupid but I have only started using Access for
about three weeks. Where exactly does the condition and action you
supplied go?
When creating the macro using the drop down selections, it look like
this:

Open table: Table name=tablename - View=Datasheet - Data
Mode =Edit
Run Command: Select all
Run Command: Delete
Close
 
JT,

In design view of your macro, if you can't see a Condition column,
select Conditions from the View menu. Then, you would insert the
StopMacro action, with the MsgBox function in the Condition column, at
whatever point in the macro where you want the message box to check for
continue or not.

On another topic, I would advise against the way you are trying to clean
the data out of your table. I would recommend making a Delete Query,
and then using an OpenQuery action in the macro to run the delete.
 
Thanks Steve for you help.

Not seeing the condition column was throwing me off. Your suggestion
worked just as I needed it. I also took your advise and built the
delete query to clean the table. I like that much better too.
I am just starting with Access but I think I have found a new tool to
play with that I find loads of fun. So far I am into my second
database and it has sure been a very satisfying learning experience
for the last three weeks.

Thanks again.
 
JT,

Great to hear that you are making good progress. Access is a fantastic
program. Many people find it a bit of a steep learning curve at first,
but perseverance pays dividends!
 
Back
Top