After Update Requery Code

  • Thread starter Thread starter Thorson
  • Start date Start date
T

Thorson

I have a form with a subform, I would like the AfterUpdate event of the combo
box cboDiagnosis to requery a combo box in the subform cboDrugName, however
when I put in the code it says it can not find the field, I think I am
identifying it incorrectly, this is the code I put in the after-update event
for CboDiagnosis:

Private Sub cboDiagnosis_AfterUpdate()
[frmTherapeuticIndTreatmentRecords.cboDrugName].Requery
End Sub

Do I have to identify differently since it is a sub-form?
Thanks.
 
The syntax for referring to a control on a subform is as follows
(if you are doing this in the code module for the main form);

Me!NameOfSubformControl.Form!NameOfControlOnSubform

It's important to note that NameOfSubformControl means the name
of the Control (the window) that contains the subform, not the
subform itself. The Subform Control may, or may not, have the same
name as the subform itself, depending on how it was created.

So in your case it would look something like;

Me!frmTherapeuticIndTreatmentRecords.Form!cboDrugName.Requery

assuming that frmTherapeuticIndTreatmentRecords is the name of the
Subform Control.
 
Thanks, it worked, I didn't think of that.
--
Thorson


MrMackey via AccessMonster.com said:
Yes. It could be tricky sometimes to access controls on subforms. Use the
build feature (temporarily from a query or something similar) to get the
correct form path to use.

Mr. Mackey
I have a form with a subform, I would like the AfterUpdate event of the combo
box cboDiagnosis to requery a combo box in the subform cboDrugName, however
when I put in the code it says it can not find the field, I think I am
identifying it incorrectly, this is the code I put in the after-update event
for CboDiagnosis:

Private Sub cboDiagnosis_AfterUpdate()
[frmTherapeuticIndTreatmentRecords.cboDrugName].Requery
End Sub

Do I have to identify differently since it is a sub-form?
Thanks.
 
Back
Top