"Clicking" a radio button with VBA (1 Viewer)

RaunLGoode

Registered User.
Local time
Today, 12:21
Joined
Feb 18, 2004
Messages
122
As part of an error check, if a field on an excel spreadsheet is black, I would like to open a form and select one of two option (Radio) buttons on the form. This would place the user in the correct place to add the missing information.
I have been unable to programically "Click" the button. in VBA.
....
If Range("I4").Value = "" Then

CatReturn.ob3.Value = False ' reset radio button in another frame
CatReturn.ob4.Value = False ' reset radio button in another frame
CatReturn.ob11.Value = False ' toggle radio button in frame fr2 off
CatReturn.ob12.Value = True ' toggle radio button in frame fr2 on
CatReturn.fr2.Visible = True
CatReturn.Show 'Make form visible

ob12 is the button I want to click but I haven't found a way to do that with VBA. could somebody tell me how to "Click" ob12?
 

Access_guy49

Registered User.
Local time
Today, 13:21
Joined
Sep 7, 2007
Messages
462
obj0.value = -1 'Means checked or marked
obj0.value = 0 'Means unchecked or unmarked,

When a form loads, by default the option buttons are set to <Null>

In your code your not accepting user input but rather telling the object what it's value should be. If you wish for your user input then you will need to place the code within the click event of the object.

Your code should test using an if statement to determine the value of object0.

if obj1 = 0 then
'Perhaps here you should test to see if object 2 has been selected
else
'set your focus to your cell that you believe the user should look at
end if


Alternativly you can have your option buttons set up and then a GO button at the bottem, and the GO button tests the value of your option buttons and do your code accordingly.
 

SOS

Registered Lunatic
Local time
Today, 10:21
Joined
Aug 27, 2008
Messages
3,517
For an Option Group inside a frame you set the value of the FRAME, not the individual options.

So, whatever the index of the item you want:

Me.fr2 = 1
 

Users who are viewing this thread

Top Bottom