group box/option box has no value (1 Viewer)

iworkonline

Registered User.
Local time
Today, 01:06
Joined
May 25, 2010
Messages
44
Hello Fellowes

I have created an option group box with 2 options and in the VBA code I have an if statement if one of the option box is sekected or not like so

Code:
If Me.optSoft.Value = True Then
    some thing 
else
    nothing
end if

I am getting this error message:
you entered an expression that has no value.

I would appreicate your help in this. Thanks.
 

boblarson

Smeghead
Local time
Today, 01:06
Joined
Jan 12, 2001
Messages
32,059
You test the value of the Option Group itself, not one of the options.

So, if your Option Group is named Frame15 (for example) you would use:

Code:
Select Case Frame15

Case 0 ' the first index number
    Something
Case 1 ' the second index number
    Nothing
End Select

And you can set the index numbers of the individual options, but any of them within the same option group can't have the same value.
 

iworkonline

Registered User.
Local time
Today, 01:06
Joined
May 25, 2010
Messages
44
Hello Bob

I am using 2 option buttons. and I don't see an index property for option button.
When I was creating the option box I remeber setting the index but I don't know how to access that value.

In the curent sample code above, I don't know how will I associate the values of the option button to the frame. thanks
 

boblarson

Smeghead
Local time
Today, 01:06
Joined
Jan 12, 2001
Messages
32,059
In the curent sample code above, I don't know how will I associate the values of the option button to the frame. thanks

First, remove your single option buttons.

Second, add a new Option Group object and then, using the Wizard you can tell it the labels to use and values and that you want to use Radio Buttons (the round things that have a dot in them when selected).

To add a Option Group click on the button that looks like this:

 

Attachments

  • optgroup.png
    optgroup.png
    6.6 KB · Views: 350

iworkonline

Registered User.
Local time
Today, 01:06
Joined
May 25, 2010
Messages
44
Hey Bob

Thanks for the illustration and that's how I created the option box using the wizard. But I did not know how to use the frame control. Initialy the frame Default Value, I set that to -1, that should have been set to the index values that I created earlier.

Secondly, I treated the option boxes as I would treat individual option boxes and changed the values to -1 and 0, which was wrong. I updated the values to the appropriate values and then I was able to excecute the code properly.

Bob, thanks for pointing me in the right direction.
 

Users who are viewing this thread

Top Bottom