Having trouble deselecting all option buttons in on my form (1 Viewer)

Finance

Registered User.
Local time
Today, 01:22
Joined
Jul 11, 2018
Messages
59
I have created a button to deselect all the option buttons on my form and I have written the following code to automate the button. The code is working in that it’s deselecting all the option buttons. My problem is that the option buttons have an embedded macro that is used to run update queries to select and deselect yes/no records on a table. If I deskect the option manually one by one the selected yes/no field is turned to false in the table. But if I use the button to deskect all the checkboxes, the selected yes/no records in the table corresponding to each option button do not deselect.

The code I am using for the deselect button is

Code:
Private sub command32_click

 Me.optionUSProvYes=False
 Me.optionNationalP=false

End sub
 

isladogs

MVP / VIP
Local time
Today, 09:22
Joined
Jan 14, 2017
Messages
18,209
Why do you need to deselect them?
Normally only one option is selected in an option group and you don't need to have a default selection
 

Finance

Registered User.
Local time
Today, 01:22
Joined
Jul 11, 2018
Messages
59
There’s an error whenever I click the checkbox. It doesn’t update the table or the macros aren’t activated the first time I click the form but it works on the second click of the option button.
Anyone know why this is happening?
 

GinaWhipp

AWF VIP
Local time
Today, 04:22
Joined
Jun 21, 2011
Messages
5,900
Hmm, well trying to figure out which problem you are trying to solve as it appears you have two issues. In your initial post you state you want to clear your Option Group. Well, they are not True\False, they are numeric so you might try NULL instead AND you only need to apply that Control (not the options themselves but the entire Control), i.e.

Code:
    With Me.YourControlName
        If .Value > 0 Then
            .Value = Null
        End If
    End With

Thought not sure why you would to clear but perhaps because you are going to a new record though it should be clear when doing that.

Second issue seems to indicate you are having a problem selecting an option. Well, is there any code in the After_Update event or the On-Current event of the Form that pertains to the Option Group? Could be that is running on your initial click which would cause the problem.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 04:22
Joined
Feb 19, 2002
Messages
43,223
What event is the macro associated with?
 

Users who are viewing this thread

Top Bottom