Updating Subform RecordSource property

redBo

New member
Local time
Tomorrow, 07:14
Joined
Jan 16, 2007
Messages
9
Hello all,

I have a subform, frmSubA, in a main form, frmMain. The subform has a "default" RecordSource set, an SQL query (SELECT * from tblFields)

I would also like to set the RecordSource of the subform from the mainform. I tried this:

Me.frmSubA (I just used the access toolbox to put subform in; so the "holder" has the same name as the subform).RecordSource = strSQL (a SQL string)

Access is complaining with the following message when I click a button to call a procedure containing the line above:
"Compile error: Method or data member not found". It also highlights the text RecordSource in the line above....

Appreciate your help.

Thanks
 
Oopss.... I got it working now...

For those interested:
me.subform.form.RecordSource = strSQL
lets you set source
 
But do you understand why that worked? It's because the subform is not a "proper" form as it were, but instead a container in the "main" form. Therefore, you have to reference it as an object.

It's little bits of knowledge like that will advance your skill in Access.
 
Nice.... Thanks for clearing that out... I just hit that randomly trying things... so proper explanation helps for novices like myself.
 

Users who are viewing this thread

Back
Top Bottom