Problem updating a subform

303factory

Registered User.
Local time
Today, 08:31
Joined
Oct 10, 2008
Messages
136
Hi

I have a form with a subform that displays results from a query. I'm trying to udate which query is used as the recordsource, using code.

I've been trying to use the following code:

Forms![frmResultsCase]![subfrmExhibitList].RecordSource = qryOpenExhibit

Where the main form is frmResultsCase (the form with the action button that calls the update function) and the sub form is subfrmExhibitList.

I'm getting the following error:

[my project] can't find the field 'subfrmExhibitList' referred to in your expression.

I'm pretty sure the syntax is correct becuase I use very similar syntax to update a subform elsewhere in my project. Any idea what I'm doing wrong?

Thanks

Dan

:confused:
 
1. You must refer to the CONTAINER name (control housing the subform on the main form instead of the subform name itself. It can be the same name but you have to use the container name if it isn't the same as the subform name)

2. Because you are trying to set the form's recordsource and not an item on the subform container, you need to use the .Form. part in between the container name and the .Recordsource part.

3. You need quotes around the query name.

So, if your names are correct then it would be:
Forms![frmResultsCase]![subfrmExhibitList].Form.RecordSource = "qryOpenExhibit"
 
1. You must refer to the CONTAINER name (control housing the subform on the main form instead of the subform name itself. It can be the same name but you have to use the container name if it isn't the same as the subform name)

2. Because you are trying to set the form's recordsource and not an item on the subform container, you need to use the .Form. part in between the container name and the .Recordsource part.

3. You need quotes around the query name.

So, if your names are correct then it would be:
Forms![frmResultsCase]![subfrmExhibitList].Form.RecordSource = "qryOpenExhibit"

Very helpful thank you! got it working now :)

Dan
 

Users who are viewing this thread

Back
Top Bottom