MessageBox (1 Viewer)

GoodyGoody

Registered User.
Local time
Today, 06:32
Joined
Aug 31, 2019
Messages
120
Hi, I have a button which runs a macro which in turn runs 3 Update Queries to finalise a process and 'fix' the results. I just want a message at the front of the Macro offering the user the choice to continue or not. On the surface MessageBox seems the obvious answer but it doesn't seem to have the interactive options that the VBA MsgBox function has. Am I missing something or do I need to do this in VBA? I've read a number of threads on this but all of them seem to end up in VBA. Thanks as ever. Stephen

BTW I'm using Access 2013
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 14:32
Joined
May 7, 2009
Messages
19,169
you wrap your update query inside the Msgbox.
marco should look like this:

IF Msgbox("do you want to update?", 36)=6 Then
 

isladogs

MVP / VIP
Local time
Today, 06:32
Joined
Jan 14, 2017
Messages
18,186
Unless you know what the various number codes mean, you may prefer something like

Code:
If MsgBox("Do you want to update now?",vbQuestion+vbYesNo, "Run update") = vbYes Then
 ...update code here
Else
  Exit Sub
End If
 

jdraw

Super Moderator
Staff member
Local time
Today, 02:32
Joined
Jan 23, 2006
Messages
15,364
Stephen,

Further to what the others have posted, and for general reference, you may find the Similar Threads area at the bottom of this (and other) thread(s) helpful.
 

Gasman

Enthusiastic Amateur
Local time
Today, 06:32
Joined
Sep 21, 2011
Messages
14,048
Colin,

If truly in a macro the vb equivalents are not recognised?, at least in 2007 they are not?

Unless you know what the various number codes mean, you may prefer something like

Code:
If MsgBox("Do you want to update now?",vbQuestion+vbYesNo, "Run update") = vbYes Then
 ...update code here
Else
  Exit Sub
End If
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 14:32
Joined
May 7, 2009
Messages
19,169
gasman is right when using Macro.

vbQuestion = 32
vbYesNo = 4

vbQuestion + vbYesNo = 36

vbYes = 6
 

isladogs

MVP / VIP
Local time
Today, 06:32
Joined
Jan 14, 2017
Messages
18,186
Hadn't noticed that the OP was using a macro.
Of course using code is MUCH easier..

Anyway, I agree - though its an odd oversight by MS in my opinion
Notice that I did know what the number codes represented :D
 

Gasman

Enthusiastic Amateur
Local time
Today, 06:32
Joined
Sep 21, 2011
Messages
14,048
It can get a little confusing as sometimes newbies refer to a piece of VBA code as a macro, presumably coming from an Excel perspective?
 

isladogs

MVP / VIP
Local time
Today, 06:32
Joined
Jan 14, 2017
Messages
18,186
Hi Gasman
Yes I agree. Though in this case the OP posted in the Macros forum so its likely that's what he/she meant
The OP is using A2013 but IIRC you can't use Else statements in macros in A2007. Ready to be corrected if necessary!
 

Gasman

Enthusiastic Amateur
Local time
Today, 06:32
Joined
Sep 21, 2011
Messages
14,048
I believe that to be the case. They do seem very limited. I've only ever used them for batch operations like running a set of queries or reports in my early days.

Now I would probably use VBA instead.
 

isladogs

MVP / VIP
Local time
Today, 06:32
Joined
Jan 14, 2017
Messages
18,186
Like most Access users, I tried macros when I first started but found them very limiting.
The macro language became more powerful with A2007 but I abandoned them for VBA long before that.
As far as I'm concerned, there are only two useful macros: Autoexec and Autokeys or at a pinch, macros used when running Access from a scheduled task
 

GoodyGoody

Registered User.
Local time
Today, 06:32
Joined
Aug 31, 2019
Messages
120
I know I can do it in VBA but from the answers above there doesn't appear to be a MACRO expression to do this. MessageBox definitely doesn't. All the examples are VBA code but I was looking for the lazy MACRO alternative. Hey ho, VBA it is. Thanks, :)
 

Gasman

Enthusiastic Amateur
Local time
Today, 06:32
Joined
Sep 21, 2011
Messages
14,048
Yes it does.
I tried out arnelgp's logic. If you put that as the first line in the macro in the condition column, then if you answer No the macros do not run.

You have the option of Else in you Access version as well.

You need to expose the Condtions column in the Macro Wizard.

In my case all I used in the Conditions column was
Code:
Msgbox("do you want to update?", 36)=6

https://sourcedaddy.com/ms-access/changing-flow-operations.html

I know I can do it in VBA but from the answers above there doesn't appear to be a MACRO expression to do this. MessageBox definitely doesn't. All the examples are VBA code but I was looking for the lazy MACRO alternative. Hey ho, VBA it is. Thanks, :)
 
Last edited:

Users who are viewing this thread

Top Bottom