|
-
May 1st, 2001, 11:45 AM
#1
Help with 2 CheckBoxes
Hi,
I have two checkboxes in my form. I want to be able to do this: Only one checkbox can be selected. if one gets selected, the other one shouldnt be (and vice versa)...Also, How do I check to see if it is checked or not? I want to make some controls invisible if checkbox1 gets selected, same for checkbox2,
Thanks a lot!!
-
May 1st, 2001, 01:12 PM
#2
Re: Help with 2 CheckBoxes
Sounds like you should be using option buttons as this is their inherent nature but if you want the look of a checkbox do this:
private sub Check1_Click(Index as Integer)
Dim i
If Check1(Index).Value = 1 then
for i = Check1.LBound to Check1.UBound
If i <> Index then Check1(i).Value = 0
next i
End If
End sub
This is assuming you use an array of checkboxes if not then you will have to copy code to each checkbox click event to set all the other checkboxes to 0.
To check if a box is checked or not just do:
if Check1.Value = 1 'or the constant vbChecked
-K
-
May 1st, 2001, 01:20 PM
#3
Re: Help with 2 CheckBoxes
Thanks a lot!!!!
Maybe you can help me with this too: I have a comboBox that loads all records from field ("SourceFileName")
If rs Is Nothing Then
Exit Sub
End If
With rs
'Are there any records?
If .BOF And .EOF Then
Exit Sub
End If
'Load the control, starting from the record
'current in the recordset
Do Until .EOF
cmbFiles.AddItem .Fields("SourceFileName").Value
cmbFiles.ItemData(cmbFiles.NewIndex) = .Fields("UploadID").Value
.MoveNext
Loop
End With
This will display everything in the combobox. Now, I have no idea how to get the Id's for each of the records ("UploadID"); I can actually "get" them, but I need to be able to, based on a selection in the ComBoBox, I will grab the ID("uploadID") from the selected value in the combobox so I can Use it ro perform a query. How can I do this?????????
Thanks again,
herick
-
May 1st, 2001, 01:22 PM
#4
Re: Help with 2 CheckBoxes
The functionality that you describe is that of the option buttons, but here's a workaround using the checkboxes.
private Sub Check1_Click()
Check2.Value = IIf(Check1.Value = vbChecked, vbUnchecked, vbChecked)
End Sub
private Sub Check2_Click()
Check1.Value = IIf(Check2.Value = vbChecked, vbUnchecked, vbChecked)
End Sub
To make a control invisible just set the visible property to false as in
text1.visible = false
David Paulson
-
May 1st, 2001, 02:47 PM
#5
Re: Help with 2 CheckBoxes
in the control's click event put this:
dim id
id = cmbFiles.ItemData(cmbFiles.ListIndex)
This will give you the UploadId that you stored during the additem procedure
-K
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|