Help with Macro To Select Option Button

mrmmickle1

Well-known Member
Joined
May 11, 2012
Messages
2,461
I have an Option Button on a Form that I would like to mark to True.

The Form is: [Forms]![Contract Master Form]!

Option Group : [Form_Options]

The Radio Button Name : [Change_All]

My issue occurs when I try to add a new Record. I have it set up so when the command Button [Add_Record] is pressed that the Focus is set to a specific field [Payor_ID]. The Problem is that if Radio Button [Change_All] is not selected all of the Form Entry fields are:

SetProperty, Enabled, 0

Meaning that when the button is clicked the field [Payor_ID] cannot be selected due to the Value being set to 0. How can I change the Macro to select Change_All Option Button? When this option button is selected a macro runs that will set all of the Values to 1:

SetProperty, Enabled, 1

Can someone please assist me. I'm not used to using dropdowns to create macros. I usually write them from scratch in the Excel VBE ... but the Access Macro structure is very different then what I'm used too.

Thanks for your time.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
To set the option button value, I would just set the Value property to be True:

Code:
Change_All.Value = True

However, this will not trigger the option button's click event that is going to enable entry fields. So I'll also need to call the option button's associated click procedure and final look will be like following:

Code:
Private Sub Add_Record_Click()
    Change_All.Value = True
    Call Change_All_Click
    Payor_ID.SetFocus
    '....
End Sub


Private Sub Change_All_Click()
    Payor_ID.Enabled = Change_All.Value
End Sub

I hope this gives an idea.
 
Upvote 0
Smozgur,

Thanks for the assistance. I am using the Macro Tool to create the Procedure. I ended up using this:

SetValue
Item: [Form_Options]
Value = 4

The OptionButton Value was 4.....

I knew this was pretty simple. Just not to familiar with the way things are done in Access. Try Try Again right....

If I wanted to link a Macro to a Form using the action drop down how do I do this?

I put the Macro in the Form Module and Made the Sub Private Sub OptionButton() and tried to link it using RunMacro & Run Code but neither of them worked....
In the future I would very much prefer to write these types of things by hand, is there a simple way to accomplish this?
 
Upvote 0
If I wanted to link a Macro to a Form using the action drop down how do I do this?

Open the form in design view, right click on the drop down and select Build Event. You will need to select Code Builder to use this object's methods in VBA. You can see your drop down name in the object box and procedure name (i.e. Click, Change) in procedure box right above the VBE code window.

Note: When you say "Macro", I take it as VBA procedures.
 
Upvote 0

Forum statistics

Threads
1,221,889
Messages
6,162,627
Members
451,778
Latest member
ragananthony7911

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top