frame option stored values

mafhobb

Registered User.
Local time
Today, 17:44
Joined
Feb 28, 2006
Messages
1,249
Can a frame with two option buttons store YES/NO instead of 1/2?

I need to show the value of a field controlled by two option buttons in one single frame in a listbox and I need it to show up as yes/no instead of 1/2

mafhobb
 
Last edited:
The response to clicking an option button in a frame is the ordinal position of that button (always numeric). If you need Yes/No values to be displayed, you need to convert the numbers. If your frame is named fraTest, you need its AfterUpdate event to convert the value to what you need, e.g.
Code:
Private Sub fraTest_AfterUpdate()
Dim strResult As String
Select Case Me.fraTest
Case 1: strResult = "Yes"
Case 2: strResult = "No"
Case Else: strResult = vbNullString
End Select
End Sub
The Case Else is good practice, in case you add new options in future and forget about this aspect of the coding. Without it, anything other than 1 will always be treated as 2 (the final case in a Case statement without the Case Else).
 
Ok. That makes sense, but how do I make my field "Leido" have that value?

My opt buttons are named opt45 and opt47. Do I just write the value "Yes/No" directly to the table? How?

mafhobb
 
you do not use the opt buttons directly - use the value of the frame, and use the after update event of the frame. ignore the buttons. the frame manages the buttons

so, just this will do it

sub frame_afterupdate
someyesnofield = (frame = 1)
end sub

(frame=1) either evaluates as true, or false, depending which button was clicked

so your yes/no field is assigned true or false by this expression
 

Users who are viewing this thread

Back
Top Bottom