Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to code toggle buttons in a group frame 1

Status
Not open for further replies.

SkyHigh

Technical User
May 30, 2002
309
CA
Hi

I have a group frame on a form with 3 toggle buttons, the following code does not work for and results in "You entered an expression that has no value", can some please help me in coding it correctly - thanks.

Private Sub btnOK_Click()
On Error GoTo Err_btnOK_Click
Dim vOpt1 As Boolean
Dim vOpt2 As Boolean

If Me.tglBOTH.Value = True Then
vOpt1 = True
vOpt1 = True
End If
If Me.tgl1.Value = True Then
vOpt2 = False
vOpt1 = True
End If
If Me.tgl2.Value = True Then
vOpt1 = False
vOpt2 = True
End If

MsgBox "Toggle 1 is set to : " & vOpt1 & vbCrLf & _
"Toggle 2 is set to : " & vOpt2

Exit_btnOK_Click:
Exit Sub

Err_btnOK_Click:
MsgBox Err.Description
Resume Exit_btnOK_Click

End Sub
 
Hi,

What is the tglBOTH object?

Regards,

Darrylle

Never argue with an idiot, he'll bring you down to his level - then beat you with experience. darrylles@yahoo.co.uk
 
Hi again,

If you have an option 'frame' - then surely you can only have ONE option that is true - no?

You seem to be messing with these option buttons and setting them in code.

It seems that you have 3 option buttons.
In an option group, only ONE can be ON at one time (even if there are 50 buttons - only ONE can be true).

What are you attempting to do?

Regards,

Darrylle

Never argue with an idiot, he'll bring you down to his level - then beat you with experience. darrylles@yahoo.co.uk
 
Hi

I added an option group to a form using wizard I add 3 option buttons i.e. tgl1,tgl2 and tglBOTH then I selected Toggle Button, true that only one button/option can be true at any given time and thats what I am trying to figure out how can I dectect a true condition for one of these three toggle buttons using VBA

Thanks.
 
When you used the wizard, you gave each of the buttons a value. That value can be retrieved from the option group (the whole frame as Darrylles refers to), the wizard typically names it "FrameN", where N is some numeric

So if you chose values 1, 2, 3 for the buttons, then you can

[tt]select case me!Frame99
case 1
' first selected
case 2
' second seleted
case 3
' third selected
end select[/tt]

- for instance in the option groups after update, forms on current...

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top