Access World Forums

Access World Forums (https://www.access-programmers.co.uk/forums/index.php)
-   Macros (https://www.access-programmers.co.uk/forums/forumdisplay.php?f=11)
-   -   MessageBox (https://www.access-programmers.co.uk/forums/showthread.php?t=306966)

GoodyGoody 09-21-2019 08:32 AM

MessageBox
 
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 09-21-2019 08:40 AM

Re: MessageBox
 
you wrap your update query inside the Msgbox.
marco should look like this:

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

isladogs 09-21-2019 09:18 AM

Re: MessageBox
 
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 09-21-2019 09:27 AM

Re: MessageBox
 
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 09-21-2019 09:59 AM

Re: MessageBox
 
Colin,

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

Quote:

Originally Posted by isladogs (Post 1641339)
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 09-21-2019 10:22 AM

Re: MessageBox
 
gasman is right when using Macro.

vbQuestion = 32
vbYesNo = 4

vbQuestion + vbYesNo = 36

vbYes = 6

isladogs 09-21-2019 10:32 AM

Re: MessageBox
 
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 09-21-2019 11:02 AM

Re: MessageBox
 
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 09-21-2019 11:09 AM

Re: MessageBox
 
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 09-21-2019 11:20 AM

Re: MessageBox
 
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 09-21-2019 11:49 AM

Re: MessageBox
 
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 09-21-2019 01:41 PM

Re: MessageBox
 
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 09-22-2019 12:39 AM

Re: MessageBox
 
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/ch...perations.html

Quote:

Originally Posted by GoodyGoody (Post 1641375)
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, :)



All times are GMT -8. The time now is 04:01 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World