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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set default for Option Group

Status
Not open for further replies.

RenaG

Programmer
May 3, 2011
132
US
I am working in Access 2007. And I am an extreme newbie to Access.

I have 3 tables:
User
ID FirstName LastName
Program
ID ProgramName
ProgramUserXRef
ID UserID ProgID

My form consists of an unbound ComboBox whose Row Source is the User table. I added an Option group that displays the Programs. I want the default for this group to come from the combobox when the user selects their name.

It seems like I should use a SQL statement but when I click on the "..." next to Default Value it just brings up the Expression Builder and I am not sure how to create a SQL statement in it. Any suggestions on how I can do that?

TIA!
~RLG
 
Your table structure suggests you will have more than one program associated with a user.... How do you know which program you want.


That being said, default value is not what you want. You want to fill in the program based on a user selection...

So on the unbound user combobox's after_Update event you would want to set the value of the ProgramID if it is blank...


What is the name of the PrgramID control?

Your user combobox should be updated to contain the default program so we can grab that out of it... Or we could lookup the value based on the combobox value but I like my idea better.


What is the name of the unbound username combobox?
 
Hi Iameid,

Sorry it has taken me a little bit to get back to you. Thank you for replying.

Yes, it is true that a user can be involved in more than one program, but this will rarely be the case. When that is true, the only thing to do is to set the default to the first match it finds and she will have to change the option group if that is not the one she wants.

The name of the PrgramID (I think you mean the Option Group?) is 'Program'. Would it be better to name is something like optProgram?

The name of the username combobox is cmbUser.

Your user combobox should be updated to contain the default program so we can grab that out of it...

Please explain how to do this.

Thanks for all your help.

~RLG
 
FYI ~

I got the answer to my combobox/option group question.

I added the ProgramUserXRef table to the User table in the SQL stmt on the combobox so that I had available to me the programID. Put in the after Update event
Code:
Me!optProgramID.DefaultValue = Me!cmbUser.Column(3)
Me!optProgramID.Requery

Worked like a charm!

~RLG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top