Getting macro to work?

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

Guest

I created a macro that handls different tasks in Access. Well, I have the
conditions set to "tgldinneryes.ongotfocus" then for it to setvalue to
"txtdinneramount" and to be "8.00". And the same for
"tgldinnerno.ongotfocus" for it to set value to "txtdinneramount" to be
"0.00". It runs, but no matter what toggle button is pushed it shows "0.00".
I have put it under different event procedures and messed with it for a
while now, but it will never show "8.00" when the toggle yes button is
clicked. What am I doing wrong?
 
You should not be using the GotFocus event here, but instead, the
AfterUpdate event. The question is, for which control? :-)

It sounds as if tgldinneryes and tgldinnerno are members of an option group.
Is this correct? If so, then tgldinneryes should have an option value of
True (or -1) and tgldinnerno should have an option value of False (or 0).

Then, you use the AfterUpdate event of the _option group_. If the yes
button is pressed, the option group will have a value of True, and if the No
button is pressed it will be False. Let's say your option group is named
opgDinner.

Private Sub opgDinner_AfterUpdate()
If opgDinner Then
txtDinnerAmount = 8.00
Else
txtDinnerAmount = 0
End If
 
Thank you so much. That was really beginning to annoy me. It works
perfectly now.
 

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

Back
Top