Referencing a subform from Mainform

liamfitz

Registered User.
Local time
Today, 00:13
Joined
May 17, 2012
Messages
240
The following line of code is producing an error -
Code:
Me!sfrmReferrals.Form!sfrmReferralsClosed.Form.RecordSource = refSQL
Microsoft Access can't find the field 'sfrmReferralsClosed' referred to in your expression. I have followed the syntax on the link in Access FAQ, and treated the recordsource in my code, as both being called as Sub1 and Sub 2. Both are producing this error. Any ideas ?:o
 
What do you want it to do ? Outcome?
 
I want it to set the recordsource of this subfrom, to the String 'refSQL' used in my command line, and display the recordset created in the said subform ( the next line is
Code:
Me.sfrmreferraslClosed.Form.Requery
- but tyhe syntax for thsi would be the same as the line causing the error, once that is right. Thanks.:confused:
 
Changing the RecordSource of a form automatically requeries so the Requery line is not required.

Note that sfrmReferralsClosed needs to be the name of the subformcontrol. The name of the subform object itself doesn't matter. Although the wizard makes it the same same as the subform object it is possible to change either the subform name or the subformcontrol name independently.
 
Thank you and sorry Galaxiom, as I don't really understand the distinction you stress in your last posting ( between the subfrom object and control )It's half working now, but still a glitch. Here's the S.P.

I have a tabbed control with two tabs, each of which has a subform in - sfrmReferrals and sfrmReferralsClosed. The latter has a different selection criteria as the name suggests, i.e ALL referrals that are closed.
Their Recordsources are set in properties on two different queries - qryOpenReferrals and qryClosedReferrals.
What is now happening is sfrmReferrals is working as it should, but when I click the tab for Closed Referrals, it shows the first Client's record ONLY, and doesn't change automatically as I move through the main forms' recordset ? Any thoughts.:confused:
 
Thank you for your inquiries and help. It's now working. My fault for not checking my code and program thoroughly. I had not included in the problematic subform's recordsource/recordset, the most important field 'Client_ID', which is used as the link Master/Child field ( in both sub forms ). Once corrected, it allowed me to set this, and now works perefctly. Thank you.
 

Users who are viewing this thread

Back
Top Bottom