Calculating total in macro?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to get the total of certain textboxes on my "frmentry". I have
the macro's working properly to put certain amounts in the textboxes when
toggle buttons are pressed, but the total never shows anything. All the
textboxes are updated instantly when I push a toggle button, so that is fine.
But my macro for the total, never does anything. It just stays blank. I
have it adding up all the textboxes: txtmailoutamount, txtshuttleamount,
txtdinneramount, txtentryamount, and txtxxl (these are the textboxes getting
updated by the macros). The total is supposed to be updated as certain
toggle buttons are pushed. Any ideas why it is not doing anything?
 
escudolm said:
I am trying to get the total of certain textboxes on my "frmentry". I
have the macro's working properly to put certain amounts in the
textboxes when toggle buttons are pressed, but the total never shows
anything. All the textboxes are updated instantly when I push a
toggle button, so that is fine. But my macro for the total, never
does anything. It just stays blank. I have it adding up all the
textboxes: txtmailoutamount, txtshuttleamount, txtdinneramount,
txtentryamount, and txtxxl (these are the textboxes getting updated
by the macros). The total is supposed to be updated as certain
toggle buttons are pushed. Any ideas why it is not doing anything?

What triggers the macro? Depending on the macro, I am guessing you need
to trigger the execution of the macro to occur after all the text boxes are
updated.
 
Personally, I'd not go through the hoops of building a macro, I'd just build
a simple statement in code and put it in the appropriate event. When do you
want it to fill in the total?
 
Well, I have the macro running on the afterupdate event in the textbox for
the total. I want the the total textbox to be updated all the time. So if a
person pushes a toggle button, the amount goes into that textbox and then the
total textbox shows that amount plus any other amount in the other textboxes.
And if they take off something by pushing another toggle button, then the
new total is put in the total textbox. Hopefully this makes sense.
 
I could be wrong, but I think AFTERUPDATE runs after you save the record.
It look like ONCHANGE, might work, or simply add it to the other macros.

If Macro1 puts some value in the total box, instead, have it put that value
plus whatever else. In other words, don't have one macro run and then
expect another to run as soon as that one is done, just do it all in one
macro.

Again, if it were me, I'd get rid of all the macros and just write a simple
one or two line code. Macros have limited ability, and they clutter up the
database. Just write code.
 
Well, I was going to just write code but wanted to try a macro since I
normally don't mess with them too much. Actually I got it to run perfectly
now. I just had to put the calculation in the control source for the
textbox. Thanks.
 
Rick said:
I could be wrong, but I think AFTERUPDATE runs after you save the
record. It look like ONCHANGE, might work, or simply add it to the
other macros.
If Macro1 puts some value in the total box, instead, have it put that
value plus whatever else. In other words, don't have one macro run
and then expect another to run as soon as that one is done, just do
it all in one macro.

Again, if it were me, I'd get rid of all the macros and just write a
simple one or two line code. Macros have limited ability, and they
clutter up the database. Just write code.

To comment on Rick's suggestion, macros are more likely to cause you
problems than well written code. Also the code can be easier to understand
and is less likely to get stepped on.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top