|
-
November 24th, 1998, 12:24 PM
#1
Binding option buttons to data
I have a form with bound controls to a data source.
The text and list controls work ok but I can't seem to
get the option button to update when I change records.
What it the best way to update the option buttons and
check marks when changing to a new record.
Thanks for any replies.
-
November 25th, 1998, 03:16 AM
#2
Re: Binding option buttons to data
As far as I know, you cannot bound datacontrols to option buttons.
You could write one your own (with VB 5 / 6).
Or write a wrapper function, which reads the datafield, and depending on that value set an option-button on or off.
Hope it helps
Crazy D
-
November 27th, 1998, 12:19 PM
#3
Re: Binding option buttons to data
Tim-
The best way I have found is to bind the field to a HIDDEN text box, and use events to tie it to a checkbox.
For example:
'' Triggered by user action
Private Sub Check1_Click()
'' Use 1 for checked, 0 for unchecked
If (Check1.Value = vbChecked) Then
Text1.Text = "1"
Else
Text1.Text = "0"
End If
End Sub
'' Triggered by record refresh
Private Sub Text1_Change()
If (Text1.Text = "1") Then
Check1.Value = vbChecked
Else
Check1.Value = vbUnchecked
End If
End Sub
You may think that this would cause an endless loop, but VB stops firing events if the data doesn't change.
This also allows you to make a "Y/N" (character) field into a checkbox.
-Jim
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
|