Radio Buttons and VBA coding

G

Guest

hi,

first off, i'm using A2K.....in case it really matters.

i have a form on which there is a group of 7 radio buttons which determine
the value of a control called "Outcome_" that can take on values 1,2,3,...,7
in the table underlying the form.

what i'm trying to do is work up a scenario whereby when the user enters the
form and the value on the form's not 5 or 6 or 7 (because buttons 1,2,3 or 4
were depressed already)

1) and the user selects a 5, the effect is to launch a macro which actuates
a update query that appends a record into a linked table.

2) and the user selects a 6 (or a 7) the effect is to launch a macro which
actuates an update query that works against the linked table.

when the value of the radio button is either 5, 6 or 7 and the user selects
either a 1,2,3 or 4, the effect is to launch a macro which actuates a query
to delete the record in the linked table.

i reckon that what i'm trying to achieve would be implementable via using an
OnClose event and would be testable against the value of the Outcome_
variable at that point.

am i understanding all this correctly?

-ted
 
G

Guest

I'd consider the OnChange event for that radio button. You can then set a
global Boolean to indicate that a specific task is to be performed. Then in
the form's OnClose event, you can test the boolean(s) and take whatever
action you want.
 
G

Guest

dennis,

i researche the OnChange event for each of the radio buttons in the Frame
and failed to find a one. each one has a name beginning with Toggle and is
concatenated with a number, e.g. Toggle9 and so forth?????
 
G

Guest

i've done a bit more snooping behind the scenes and find a reference to a
'Frame1' control which appears to map to the 'box' housing the buttons on the
form. there's a Select Case statement which i find in a
'Frame1_AfterUpdate()' event vba which has the cursor moving to date fields
to the right of each button as a function of the Case 1,2,3,....,7
so......perhaps i could try working something into the forms OnClose event
which uses the Select Case of the Frame1.Value concept?
 
G

Guest

In order to use the values in those buttons, you reference the value of the
FRAME.

So,

Select Case Frame1
Case 1

Case 2

etc
End Select

And use the ON Change event for the FRAME.
 
G

Guest

I bit more:

At the On Close event for the form, query the value of the FRAME, and take
action accordingly.
 
G

Guest

ok, but i don't see an OnChange attached to the Frame1....i do see
AfterUpdate, perhaps the same?
 
G

Guest

As I said in my earlier post.

Select Case Frame1
Case <value1>
do stuff
Case <value2>
do different stuff
Case etc....
End Select
 
G

Guest

so, let me try to piece your collection of responses together. if i use the
Select Case Frame1.value statement as you suggested in the OnClick of
Frame1's, can you enlarge on this?
 
G

Guest

The correct way to do this would be to use the After Update event of the
option group. I would suggest a Select Case statement to process the values.
If you need to know what the previous value for the current record was, you
can use the OldValue property.

Select Case Me.opgOutcomes
Case 1
'Do stuff for 1s
Case 2
If Me.opgOutcomes.OldValue = 5 Then
'Do whatever when it changes from 2 to 5
Else
'Do something else
End If
Case 3
etc
End Select

Hopefully, this will get you going in the right direction. Beware the evil
Change event. You wont notice it much in an Option Group, but it fires every
time a change happens in a control. For example, in a Text Box, if you type
"Foo", it fires after the F, the first o, and the next o. Then when you hit
enter, the After Update fires.
 
G

Guest

i had begun to think in terms of the OldValue property when i was interrupted
by a phone call. thanks for the wakeup call.
 
G

Guest

this has got to be a really reallly dumm question, but what does the 'opg' in
Me.opgOutcomes.OldValue mean?
 
G

Guest

event for Frame1_click:

Private Sub Frame1_click()

Select Case Frame1
Case <value1>
do stuff (like set a flag)
Case <value2>
do different stuff (like set a different flag)
Case etc....
End Select

End sub
----------------------------
Event for form closing:

Private Sub OnClose_mYForm()

Do stuff here based upon your evaluation of the Frame values in the above
Sub....

End sub
 
G

Guest

It is only part of a name, you can ignore it. Since I did not know your
naming, I used my own.
It is part of the normal naming standards I have adopted. Each object has a
prefix so you know immediately what it is.
txt = Text Box
cbo = Combo Box
lst = List Box
cmd = Command Button
opg = Option Group
frm = Form
rpt = Report
etc.
 
G

Guest

i WAS acquainted with the others in your list but when i looked at it, opg
didn't strike me as being familiar....it makes sense once you know it.

thanks,

-ted
 
G

Guest

He works at a wrecking yard in Seattle melting down junk cars with his death
ray. He hates it there because the damp climate makes his joints ache, but
he wont leave because the money is good.
 

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

Top