select all option button (1 Viewer)

FahadTiger

Member
Local time
Tomorrow, 00:58
Joined
Jun 20, 2021
Messages
115
Hi my Expert..
I have button to select or deselect all OptionButton in continuous form and change its caption ...but its select just first OptionButton ..not all OptionButton
Private Sub cmdSelectAll_Click()
' Toggle the state of OptionButton1
Me.OptionButton1.Value = Not Me.OptionButton1.Value

' Change the caption of the command button
If Me.OptionButton1.Value = True Then
Me.cmdSelectAll.Caption = "Deselect All"
Else
Me.cmdSelectAll.Caption = "Select All"
End If
End Sub
any advice...thank you
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 16:58
Joined
Feb 28, 2001
Messages
27,188
OK, if you have multiple bound records in a continuous form and EACH RECORD potentially has a "Select" or "Deselect" button independently from the "Select All/Deselect All" button, then your code is missing two more parts. Where you change the captions, either one line before OR one line after, you need to issue something similar to:

Code:
UPDATE mytable SET one-record-option-field = TRUE
or
Code:
UPDATE mytable SET one-record-option-field = FALSE

after which you might wish to do a Me.Requery to recapture the option button states from each record.

Note that if you DO NOT have multiple bound records (more specifically, the option buttons are unbound) then you cannot do this as continuous forms only has one copy of each control.
 

FahadTiger

Member
Local time
Tomorrow, 00:58
Joined
Jun 20, 2021
Messages
115
OK, if you have multiple bound records in a continuous form and EACH RECORD potentially has a "Select" or "Deselect" button independently from the "Select All/Deselect All" button, then your code is missing two more parts. Where you change the captions, either one line before OR one line after, you need to issue something similar to:

Code:
UPDATE mytable SET one-record-option-field = TRUE
or
Code:
UPDATE mytable SET one-record-option-field = FALSE

after which you might wish to do a Me.Requery to recapture the option button states from each record.

Note that if you DO NOT have multiple bound records (more specifically, the option buttons are unbound) then you cannot do this as continuous forms only has one copy of each control.
I Know that to use
docmd.RunSQL " UPDATE..."
thanks for your response
 

Users who are viewing this thread

Top Bottom