garethedmondson (26th January 2009)

Hi,
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:
runMacro
If button1 is clicked then
read guest_points
if guest_points is less than 150 then
run errormessageMacro
else
continue running the subtraction and field update to remove 150 points.
Any help is appreciated,
Many thanks
Gareth

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.
garethedmondson (26th January 2009)

Hi,
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.
Screenshot attached.
Gareth
Last edited by garethedmondson; 26th January 2009 at 11:38 PM.

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
garethedmondson (27th January 2009)

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
Gareth

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?
GJE
There are currently 1 users browsing this thread. (0 members and 1 guests)