Getting macro to work?

E

escudolm

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?
 
G

Graham Mandeno

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
 
Top