gdunn59
asked on
How to change combo box data on a subform when a certain selection is made from a combo box on a main form
I have a form1 (frmEmployee_Audits) that has a subform (frmQuality_Review_Subform ). There is a combo box (cboRegion) on form1 (frmEmployee_Audits) that if the user chooses "East" that the combo box (cboQualRevCriteria) on the subform (frmQuality_Review_Subform ) should change to a specific listing that is in a table called "tblCode_East", otherwise it should change the combo box on the subform to list the data in a table called "tblCode_West".
I have posted my code below in the Code box. When I run my code I get an error saying that it can't find the form "frmQuality_Review_Subform " referred to in a macro expression or Visual Basic Code, and the combo box dropdown(cboQualRevCriteri a) on the subform (frmQuality_Review_Subform ) is blank.
I have the code on the Deactivate Event Procedure.
What am I doing wrong?
Thanks,
gdunn59
I have posted my code below in the Code box. When I run my code I get an error saying that it can't find the form "frmQuality_Review_Subform
I have the code on the Deactivate Event Procedure.
What am I doing wrong?
Thanks,
gdunn59
Private Sub Form_Deactivate()
If Me.Region = "East" Then
Forms!frmQuality_Review_Subform!cboQualRevCriteria.SetFocus
Forms!frmQuality_Review_Subform!cboQualRevCriteria = "Combo Box"
Forms!frmQuality_Review_Subform!cboQualRevCriteria.RowSource = "select * from tblCode_East"
Forms!frmQuality_Review_Subform!cboQualRevCriteria.Requery
Else
Forms!frmQuality_Review_Subform!cboQualRevCriteria.RowSource = "select * from tblCode_West"
Forms!frmQuality_Review_Subform!cboQualRevCriteria.Requery
End If
End Sub
ASKER
It is on the Deactivate Event Procedure of form1 (frmEmployee_Audits).
Forgot to state that.
Thanks,
gdunn59
Forgot to state that.
Thanks,
gdunn59
Your subform is effectively a control on your main form.
Me.[subform_name].Form.[co ntrol_name ] =
Me.[subform_name].Form.[co
Sorry, I should clarify that. "[subform_name]" is not the name of your sub form, it is the name of the control on your form that holds the sub form. :)
"[control_name]" is the name of the control on your sub form.
"[control_name]" is the name of the control on your sub form.
ASKER
Ok, I'm still a little confused. I need the subform control_name "cboQualRevCriteria (combo box dropdown) list to change depending on what the user chooses in the main form (frmEmployee_Audits) control_name "cboRegion (combo box dropdown) list.
Thanks,
gdunn59
Thanks,
gdunn59
On your main form in design view, make sure that the sub form is not selected, then right click on the sub form, select properties, click on the "all" tab and at the very top of that list, tell me what the name is. :)
ASKER
It is:
frmQuality_Review_Subform
frmQuality_Review_Subform
Sorry, I also need to clarify what "Me.Region" is that you refer to in your code. Is that a text box that has the value of the combo box "cboRegion" in it?
ASKER
Not it is a separate combo box on the subform. That is the combo box that I need to change the data that appears in that combo box depending on what the user chooses from the combo box cboRegion on the main form.
ASKER
Sorry not on the subform, but on the main form.
ASKER
Please let me clarify.
The cboRegion combo box is on the main form (frmEmployee_Audits).
Depending on what the user chooses in this cboRegion combo box on the main form (frmEmployee_Audits), I need the combo box (cboQualRevCriteria) on the subform (frmQuality_Review_Subform ) to change based off of what was chosen in the cboRegion combo box on the main form (frmEmployee_Audits).
Hope this makes sense and I'm not confusing you too much!
Thanks,
gdunn59
The cboRegion combo box is on the main form (frmEmployee_Audits).
Depending on what the user chooses in this cboRegion combo box on the main form (frmEmployee_Audits), I need the combo box (cboQualRevCriteria) on the subform (frmQuality_Review_Subform
Hope this makes sense and I'm not confusing you too much!
Thanks,
gdunn59
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great, that worked!
You're wonderful.
I will accept the last solution you provided.
Thanks much,
gdunn59
You're wonderful.
I will accept the last solution you provided.
Thanks much,
gdunn59
ASKER
Works like a charm.
Thanks much!
Thanks much!
Happy to help :)
ASKER
Thanks,
gdunn59