Avatar of dblankman
dblankman
 asked on

How to set RecordSource for sub form

I have inherited an access application front and backend and am converting it to sql server backend.
The code that opens a form is:  [MainSub].SourceObject = "TurtleMain". This form in turn has  several subforms. I have code like this to get records for each of the subforms:

Set rsFeeding = New ADODB.Recordset
With rsFeeding
   Set .ActiveConnection = con
   .Source = "spSubFeeding " & vTurtleID & " "
   .LockType = adLockOptimistic
   .CursorType = adOpenKeyset
   .CursorLocation = adUseClient
   .Open
End With

I want to be able to set the Recordset for the subform, but the code: Set Forms!Main!MainSub.Form!TurtleFeedingSub.Recordset = rsFeeding gives me an error of "object doesn't support this property or method."

What is the correct way to set the Recordset property?
Microsoft AccessVisual Basic Classic

Avatar of undefined
Last Comment
dblankman

8/22/2022 - Mon
dblankman

ASKER
Here is a screenshot of the access form related to this question
TurtleFEMain.png
dblankman

ASKER
I was able to get this to work by using: Set Forms!TurtleMain!TurtleSubEvent.Form.Recordset = rsEvent  by opening "TurtleMain" in a separate window,but this breaks other code that is looking for Main![MainSub] syntax
ASKER CERTIFIED SOLUTION
dblankman

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck