Office Software Thread, Access - Conditional Macros in Technical; Hi,
I've got a Macro assigned to a button on a form which is a query output. When the user ...
26th January 2009, 11:06 PM #1
Access - Conditional Macros
I've got a Macro assigned to a button on a form which is a query output. When the user clicks on the button it reads a value from a field and subtracts 150. It puts the new value back into that field.
I have done this with a Macro
The Macro looks like this:
GoToControl Points Balance
SetValue [Forms]![frm_qry_choose_gift]![Point Balance], [Forms]![frm_qry_choose_gift]![Point Balance]-150
I'm looking to get some sort of conditional rule in there which reads the users points value and if they have less than 150 runs another Macro (or stops this Macro) that tells them they cannot continue.
Can anyone offer advice getting the conditional rule in there? I could use code but for this scenario it has to be a macro.
The pseudocode I want to follow is:
If button1 is clicked then
if guest_points is less than 150 then
continue running the subtraction and field update to remove 150 points.
Any help is appreciated,
IDG Tech News
26th January 2009, 11:21 PM #2
This may help:
ACC2000: How to Use a Conditional Macro to Confirm Changes to a Field
so adding them to the macro actions that you already have (in screenshot) to be performed if the condition is true should make it work.
The ellipsis in the Condition column forces Microsoft Access to perform the action on that line if the condition on the preceding line is true
Last edited by SYNACK; 26th January 2009 at 11:23 PM.
Thanks to SYNACK from:
garethedmondson (26th January 2009)
26th January 2009, 11:35 PM #3
This one is bugging me now. I have put in a line with ... but even though the points are not there and we get the error message, it is still carrying on to remove the points - moving the user into minus points.
This time I have removed the msgbox commands as they were just there for me to see how far the macro had progressed.
So I have the first condition which checks to see if the user is less than 150 points. This works and gives the error message and stops the macro. However if the condition is false and the user has more than 150 points then the macro does not run.
Last edited by garethedmondson; 26th January 2009 at 11:38 PM.
26th January 2009, 11:48 PM #4
I think it is the blank lines causing the issues, you should have something like this without the blank conditionals or blank actions:
Condition | Action
<150 | MsgBox
... | StopMacro
> 150 | GoToControl
... | SetValue
... | StopMacro
Thanks to SYNACK from:
garethedmondson (27th January 2009)
27th January 2009, 12:14 AM #5
Yes that is correct. I've just hunted out my Access for Dummies book and on page 470 is exactly what you described.
I added it and it worked. I then saw your posting.
Brilliant. That works. Not to move on....
Incidentally on dbforums.com I've been told that code is the best way to do this - even though I don't want to use code at the moment.
Amazing what you find on the web.
Many thanks once again
27th January 2009, 01:06 AM #6
How correct is the code producted by the 'Convert Macro to VBA' option?
I've started looking at the code in an attempt to increase the functionality of my exemplar project. The code looks easy enough to understand - but is this a good way to learn?
Does the conversion offer 'proper' VBA code?
By Hightower in forum How do you do....it?
Last Post: 15th June 2008, 07:15 PM
By Jobos in forum How do you do....it?
Last Post: 3rd June 2008, 02:58 PM
By randle in forum Windows
Last Post: 25th October 2007, 02:20 PM
By Midget in forum Windows
Last Post: 24th January 2007, 06:07 PM
By wesleyw in forum How do you do....it?
Last Post: 9th November 2006, 10:50 AM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread