*REPOST* Re-Query Code was working, no longer is

T

Thorson

I created a subform that had a requery coding in the event AfterUpdate for
cboDrugName, after cboDrugName was updated it would requery
cboAdministrationRoute:
Private Sub cboDrugName_AfterUpdate()
[cboAdministrationRoute].Requery
End Sub

This was working perfectly, however, I then created another requery code
using the main form. In the AfterUpdate Event in the main form for
cboDiagnosis I had a requery coding for cboDrugName:
Private Sub cboDiagnosis_AfterUpdate()
[frmTherapeuticIndTreatmentRecords]![cboDrugName].Requery
End Sub

This new requery in the main form is working great, however for some reason
once I pull up something in the cboDrugName the requery isn't working for
cboAdministrationRoute, the query linked to cboAdministrationRoute isn't
recognizing that their is anything in cboDrugName. This is the SQL for
qryDrugList (this is the query linked to cboAdministrationRoute).

SELECT tblDrugList.DrugName, tblDrugList.AdministrationRoute.Value
FROM tblDrugList
WHERE
(((tblDrugList.DrugName)=[Forms]![frmTherapeuticIndTreatmentRecords]![cboDrugName]));
 
M

Marshall Barton

Thorson said:
I created a subform that had a requery coding in the event AfterUpdate for
cboDrugName, after cboDrugName was updated it would requery
cboAdministrationRoute:
Private Sub cboDrugName_AfterUpdate()
[cboAdministrationRoute].Requery
End Sub

This was working perfectly, however, I then created another requery code
using the main form. In the AfterUpdate Event in the main form for
cboDiagnosis I had a requery coding for cboDrugName:
Private Sub cboDiagnosis_AfterUpdate()
[frmTherapeuticIndTreatmentRecords]![cboDrugName].Requery
End Sub

This new requery in the main form is working great, however for some reason
once I pull up something in the cboDrugName the requery isn't working for
cboAdministrationRoute, the query linked to cboAdministrationRoute isn't
recognizing that their is anything in cboDrugName. This is the SQL for
qryDrugList (this is the query linked to cboAdministrationRoute).

SELECT tblDrugList.DrugName, tblDrugList.AdministrationRoute.Value
FROM tblDrugList
WHERE
(((tblDrugList.DrugName)=[Forms]![frmTherapeuticIndTreatmentRecords]![cboDrugName]));

If frmTherapeuticIndTreatmentRecords is the subform (as per
your code), that SQL should never have worked. It sounds
like you made many more changes beyond just adding a
requery.

The subform reference in the query needs to be like:

....=Forms!mainform!frmTherapeuticIndTreatmentRecords!cboDrugName
or
....=Forms!mainform!frmTherapeuticIndTreatmentRecords.Form.cboDrugName

Note: Subforms are not open forms. A subform is displayed
by the subform control and is not a member of the Forms
collection.

In your reference, frmTherapeuticIndTreatmentRecords must be
the name of the subform **control** on the main form. The
name of the form object displayed in the subform control is
not used in the reference. The name of the subform control
might or might not be the same as the name of the form
object, but you must use the name of the control.
 
T

Thorson

Thank you! It works great now.
--
Thorson


Marshall Barton said:
Thorson said:
I created a subform that had a requery coding in the event AfterUpdate for
cboDrugName, after cboDrugName was updated it would requery
cboAdministrationRoute:
Private Sub cboDrugName_AfterUpdate()
[cboAdministrationRoute].Requery
End Sub

This was working perfectly, however, I then created another requery code
using the main form. In the AfterUpdate Event in the main form for
cboDiagnosis I had a requery coding for cboDrugName:
Private Sub cboDiagnosis_AfterUpdate()
[frmTherapeuticIndTreatmentRecords]![cboDrugName].Requery
End Sub

This new requery in the main form is working great, however for some reason
once I pull up something in the cboDrugName the requery isn't working for
cboAdministrationRoute, the query linked to cboAdministrationRoute isn't
recognizing that their is anything in cboDrugName. This is the SQL for
qryDrugList (this is the query linked to cboAdministrationRoute).

SELECT tblDrugList.DrugName, tblDrugList.AdministrationRoute.Value
FROM tblDrugList
WHERE
(((tblDrugList.DrugName)=[Forms]![frmTherapeuticIndTreatmentRecords]![cboDrugName]));

If frmTherapeuticIndTreatmentRecords is the subform (as per
your code), that SQL should never have worked. It sounds
like you made many more changes beyond just adding a
requery.

The subform reference in the query needs to be like:

....=Forms!mainform!frmTherapeuticIndTreatmentRecords!cboDrugName
or
....=Forms!mainform!frmTherapeuticIndTreatmentRecords.Form.cboDrugName

Note: Subforms are not open forms. A subform is displayed
by the subform control and is not a member of the Forms
collection.

In your reference, frmTherapeuticIndTreatmentRecords must be
the name of the subform **control** on the main form. The
name of the form object displayed in the subform control is
not used in the reference. The name of the subform control
might or might not be the same as the name of the form
object, but you must use the name of the control.
 

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