Go Back   Access World Forums > Microsoft Access Discussion > Macros

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 09-21-2019, 08:32 AM   #1
GoodyGoody
Newly Registered User
 
Join Date: Aug 2019
Posts: 35
Thanks: 15
Thanked 0 Times in 0 Posts
GoodyGoody is on a distinguished road
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

GoodyGoody is offline   Reply With Quote
Old 09-21-2019, 08:40 AM   #2
arnelgp
error reading drive A:
 
arnelgp's Avatar
 
Join Date: May 2009
Location: somewhere out there
Posts: 8,568
Thanks: 68
Thanked 2,744 Times in 2,629 Posts
arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice
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
__________________
"Never stop learning, because life never stops teaching"
arnelgp is offline   Reply With Quote
Old 09-21-2019, 09:18 AM   #3
isladogs
Part time moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 10,862
Thanks: 114
Thanked 2,968 Times in 2,702 Posts
isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold
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

__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Website links:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Colin (Mendip Data Systems)
Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
isladogs is offline   Reply With Quote
Old 09-21-2019, 09:27 AM   #4
jdraw
Super Moderator
 
jdraw's Avatar
 
Join Date: Jan 2006
Location: Ottawa, Ontario, Canada;West Palm Beach, Florida
Posts: 12,214
Thanks: 89
Thanked 2,020 Times in 1,968 Posts
jdraw is a glorious beacon of light jdraw is a glorious beacon of light jdraw is a glorious beacon of light jdraw is a glorious beacon of light jdraw is a glorious beacon of light
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.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
jdraw is offline   Reply With Quote
Old 09-21-2019, 09:59 AM   #5
Gasman
Enthusiastic Amateur
 
Gasman's Avatar
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 4,298
Thanks: 430
Thanked 783 Times in 760 Posts
Gasman is a jewel in the rough Gasman is a jewel in the rough Gasman is a jewel in the rough
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 View Post
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
__________________
Access novice. Sometimes trying to give something back.
Access 2007

Please, please use code tag # when posting code snippets

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Gasman is offline   Reply With Quote
Old 09-21-2019, 10:22 AM   #6
arnelgp
error reading drive A:
 
arnelgp's Avatar
 
Join Date: May 2009
Location: somewhere out there
Posts: 8,568
Thanks: 68
Thanked 2,744 Times in 2,629 Posts
arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice
Re: MessageBox

gasman is right when using Macro.

vbQuestion = 32
vbYesNo = 4

vbQuestion + vbYesNo = 36

vbYes = 6
__________________
"Never stop learning, because life never stops teaching"
arnelgp is offline   Reply With Quote
Old 09-21-2019, 10:32 AM   #7
isladogs
Part time moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 10,862
Thanks: 114
Thanked 2,968 Times in 2,702 Posts
isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold
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

__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Website links:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Colin (Mendip Data Systems)
Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
isladogs is offline   Reply With Quote
Old 09-21-2019, 11:02 AM   #8
Gasman
Enthusiastic Amateur
 
Gasman's Avatar
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 4,298
Thanks: 430
Thanked 783 Times in 760 Posts
Gasman is a jewel in the rough Gasman is a jewel in the rough Gasman is a jewel in the rough
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?
__________________
Access novice. Sometimes trying to give something back.
Access 2007

Please, please use code tag # when posting code snippets

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Gasman is offline   Reply With Quote
Old 09-21-2019, 11:09 AM   #9
isladogs
Part time moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 10,862
Thanks: 114
Thanked 2,968 Times in 2,702 Posts
isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold
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!
__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Website links:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Colin (Mendip Data Systems)
Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
isladogs is offline   Reply With Quote
Old 09-21-2019, 11:20 AM   #10
Gasman
Enthusiastic Amateur
 
Gasman's Avatar
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 4,298
Thanks: 430
Thanked 783 Times in 760 Posts
Gasman is a jewel in the rough Gasman is a jewel in the rough Gasman is a jewel in the rough
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.
__________________
Access novice. Sometimes trying to give something back.
Access 2007

Please, please use code tag # when posting code snippets

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Gasman is offline   Reply With Quote
Old 09-21-2019, 11:49 AM   #11
isladogs
Part time moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 10,862
Thanks: 114
Thanked 2,968 Times in 2,702 Posts
isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold
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
__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Website links:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Colin (Mendip Data Systems)
Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
isladogs is offline   Reply With Quote
Old 09-21-2019, 01:41 PM   #12
GoodyGoody
Newly Registered User
 
Join Date: Aug 2019
Posts: 35
Thanks: 15
Thanked 0 Times in 0 Posts
GoodyGoody is on a distinguished road
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,
GoodyGoody is offline   Reply With Quote
Old 09-22-2019, 12:39 AM   #13
Gasman
Enthusiastic Amateur
 
Gasman's Avatar
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 4,298
Thanks: 430
Thanked 783 Times in 760 Posts
Gasman is a jewel in the rough Gasman is a jewel in the rough Gasman is a jewel in the rough
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 View Post
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,

__________________
Access novice. Sometimes trying to give something back.
Access 2007

Please, please use code tag # when posting code snippets

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by Gasman; 09-22-2019 at 02:54 AM.
Gasman is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Run Yes/No MessageBox from MACRO MyTech Macros 14 01-22-2018 08:17 AM
VBA three criteria messagebox ECEK Modules & VBA 3 05-09-2017 01:18 AM
Javascript Messagebox Jarobe86 Web Design and Development 0 05-09-2013 01:29 PM
VBA MessageBox - Yes No carl6885 Modules & VBA 3 12-11-2011 09:27 AM
Messagebox help craigcain General 3 09-26-2007 06:59 AM




All times are GMT -8. The time now is 08:09 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


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