Help with Macro msgbox

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?
 
N

Nikos Yannacopoulos

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
 
S

Steve Schapel

JT,

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

Condition: MsgBox("Continue?",36)=7
Action: StopMacro
 
J

JT

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
 
S

Steve Schapel

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.
 
J

JT

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.
 
S

Steve Schapel

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!
 

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