Default Combo Box Not Firing when Form Loads

Frank123

Registered User.
Local time
Today, 00:49
Joined
Jun 29, 2016
Messages
31
Hi, I'm new to VBA and I thought this would be easy :mad:. I have subform with an unbound combo box. Upon selection, the combo box populates certain text boxes on the subform. I would like the combo box that is set to a default to automatically populate the text boxes when the subform is loaded. I have the below code to fill in the combo box default using the onload event on the subform. But when the subform does load, the combo box only shows the default value and it does not fire to populate the text boxes on the subform. I need to reselect the default from the combo box to populate the text boxes. Can anyone please tell me what I'm missing.

Me.cboDestinSiteName.DefaultValue = Me.cboDestinSiteName.ItemData(10)
 
Where are you automatically populating these text boxes? In what event?
 
Hi, Thanks for your fast reply. I'm new to VBA and access, so I hope I answer your questions. The text boxes are located on the subform with the combo box. The combo box populates the text boxes by a query that is fired upon selection from the combo box. I have code to select a default value, which is one of the combo box selections. This code fires on the onload event on the subform. However, the text boxes associated with the default value does not populate when the code fires.
 
Sorry but my email post office is sick right now so I never got notifications of your post. Are you saying that the RecordSource of the SubForm is set by the ComboBox selection?
 
Hi Frank,
Just to check I'm reading you correctly:
All the activities you require are in the Subform;
The text boxes are supposed to populate on selection from the Combo Box;
You have code in the On Load event of the subform to select from the Combo Box;
This selection doesn't populate the text boxes.

OK - first, most events that trigger code only work manually, e.g. when you physically click to update the Combo Box.

But, the event that triggers the text box updates can still be called from the Form Load event. For example the event sub that triggers the update might be:

Code:
Private Sub cboDestinSiteName_AfterUpdate()
If you wanted to trigger that code from the subform On Load event, you put in a line:

Code:
Call cboDestinSiteName_AfterUpdate
in the Subform Load event.

See if that works.
 
Hi Dave, thank you so much...it did work.

Hi RuralGuy, thank you so much for helping.
 

Users who are viewing this thread

Back
Top Bottom