After Update Requery Code

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.
 
B

Beetle

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.
 
T

Thorson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top