Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Option Group Value

Status
Not open for further replies.

LarryDeLaruelle

Technical User
May 19, 2000
1,055
US
Is it possible to set the value of an option group using VBA?

I have an option group for school semesters and would like to set the selection based on semester dates.

I have tried to assign the value to the bound frame using:

fraSemester = intQtr (intQtr is set using a date comparison test) and get the response that I can't set a value for the object.

I have also tried to set the Value and OptionValue and tried to set the specific option button OptionValue.

Access Help doesn't in this case.

Larry De Laruelle
ldelaruelle@familychildrenscenter.org

 
Larry,

This should be quite straight forward.

In the code module of your form holding the option groupd, add the following;

Code:
Me.MyOptionGroup.Value =
1/2/3 etc.

I normally initialise an OG in the Form_Open() Event, but you can have this in the Click() event of a command button or wherever you like.

Hope this helps.

Leigh Moore
Solutions 4 MS Office Ltd
 
Leigh:

Thanks for the response. It seems that the problem is not the code.

The database I'm working on is one I created at home and brought into the office to tinker with. For some reason, probably resulting from references, what will work on a db built here at the office won't work with this one.

I've tried to set the references to the same selections and sequence but I just can't seem to get this to work right -- driving me crazy.

Again, thanks for the post.

Larry De Laruelle
ldelaruelle@familychildrenscenter.org

 
What line of code is erroring out?

The Value property of an OptionGroupFrame should be set to correspond with the OptionValue number on an Option (Radio) Button, Checkbox, or Toggle Button as these are the only 3 controls that has an OptionValue property.

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
When the going gets tough, the tough gets going.
 
Ronald:

You and Leigh are right.

If I do this on any database I've developed in the office, it works fine. I did a quick test and the code:

fratest = 1

executes perfectly.

Why it doesn't work on the one I developed at home, I don't know. I set all the references the same, but it just will not accept that value assignment.

I think I may have a later service pack installed here than at home; I'll check that tonight.

Thanks for the response.



Larry De Laruelle
ldelaruelle@familychildrenscenter.org

 
Time for a Duh! award.

I think that the problem is that the option group is bound to a field in the underlying table.

The form opens to a new record and, it seems, that I can't assign a value to that bound control.

I think I have solved the issue by placing the assignment code in the after update event of one of the required fields.

Thanks guys.

Larry De Laruelle
ldelaruelle@familychildrenscenter.org

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top