Combo Box Default Value on Subform (1 Viewer)

Frank123

Registered User.
Local time
Today, 14:22
Joined
Jun 29, 2016
Messages
31
Hi, I'm new to VBA and Access. I need help with showing the default value in a combo box on a subform. I have a main form with a combo box that is linked to a subform. The subform also has a combo box. Is there a way to have the default value show in the combo box on the subform when the combo box value on the main form changes?
 

jdraw

Super Moderator
Staff member
Local time
Today, 14:22
Joined
Jan 23, 2006
Messages
15,379
Frank,

Could you describe your issue in real terms with examples rather than general? I'm sure something can be done, but as always the devil is in the details.
 

Frank123

Registered User.
Local time
Today, 14:22
Joined
Jun 29, 2016
Messages
31
Hi, thanks so much for your fast reply. I hope I explain this correctly. I have a main with a combo box that shows company site names. The main form is linked to a subform with a combo box that shows recycling facilities the company sites can use. The company basically uses one primary recycling facility (i.e., the default value). I would like the combo box in the subform show the default value (i.e., primary recycling facility) when the combo box in the main form changes to a different company site. Can this be done?
 

jdraw

Super Moderator
Staff member
Local time
Today, 14:22
Joined
Jan 23, 2006
Messages
15,379
For clarity,

Each Company Site may have a different Primary Recycling Facility??

If so, the construct you are looking for is called cascading combo.
Briefly, if you choose CompanySite X, then there is a PrimaryRecyclingFacility , say Facility 9.
And if you choose CompanySite K, then the appropriate PrimaryRecyclingFacility is say Facility 336
 

Frank123

Registered User.
Local time
Today, 14:22
Joined
Jun 29, 2016
Messages
31
Sorry for not being clear. Each company site uses the same primary recycling facility. Therefore, when the combo box on the main form changes to a different company site, I would like the combo box on the subform to change to the primary recycling facility (i.e., the default value).
 

jdraw

Super Moderator
Staff member
Local time
Today, 14:22
Joined
Jan 23, 2006
Messages
15,379
If it's always the same facility, why is it a combo? Couldn't you just assign the same value? Or are you saying now and then there is an option?
 

Frank123

Registered User.
Local time
Today, 14:22
Joined
Jun 29, 2016
Messages
31
Good question...Yes, now and then the company sites do use a different recycling facility other than the primary one. The reason I would like to show the primary recycling facility in the combo box on the subform is because the primary facility sometimes changes. By showing the default value in the combo box, our company sites know which one to use first. I hope this helps.
 

Orthodox Dave

Home Developer
Local time
Today, 19:22
Joined
Apr 13, 2017
Messages
218
Hi Frank,

We're all new - most of my training was via Access VBA for Dummies!

The first thing is there needs to be a way of identifying which is the default Recycling Facility in the (presumably) Recycling Facilities Table. This could be a boolean (yes/no) field, e.g. called Default Facility for example. (Make sure there is only one!). Then in the Default Value property of the Recycling Facility control in the subform you need a DLookup value that looks up the ID of the facility with the default value set to Yes.

Simple as that. Then you can still select a different Recycling Facility if required.
 

Frank123

Registered User.
Local time
Today, 14:22
Joined
Jun 29, 2016
Messages
31
Hi Dave, I just got back from vacation. Thanks so much. I'll give it a try.
 

Users who are viewing this thread

Top Bottom