How to pick up sourceobject from another form? (1 Viewer)

June7

AWF VIP
Local time
Today, 07:12
Joined
Mar 9, 2014
Messages
5,470
Still don't understand what you want to do. Do you want to set SourceObject or set RecordSource?

Again, suggest naming container different from object it holds.
 

Newbie8

Banned
Local time
Today, 08:12
Joined
Jun 29, 2019
Messages
30
Newbie8 wrote



If your code is in Subform1 then the syntax is
Code:
me.parent.sfSubform2.Form.recordsource
where sfSubform2 is the control name of Subform2 in the parent form

I made a mistake, the code is on the mainform.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 16:12
Joined
Feb 19, 2013
Messages
16,607
I am trying to do form_formb.sourceobject = "formb" but sourceobject not showing as an option.
I am trying to do this Me!Subform1.Form!Subform2.Form.RecordSource on the main form
The only problem I need help with picking up the source object for subform1

I'm now totally confused - sourceobject or recordsource? formb or subform2 or subform1?

on the basis you want to know the sourceobject of subform2 which in located on subform1 of another form and the code is in that form then the code is

Me.Subform1.Form.Subform2.sourceobject
 

Newbie8

Banned
Local time
Today, 08:12
Joined
Jun 29, 2019
Messages
30
I'm now totally confused - sourceobject or recordsource? formb or subform2 or subform1?

on the basis you want to know the sourceobject of subform2 which in located on subform1 of another form and the code is in that form then the code is

Me.Subform1.Form.Subform2.sourceobject

That is correct, but when I type that I only can use record source and not source object
 

CJ_London

Super Moderator
Staff member
Local time
Today, 16:12
Joined
Feb 19, 2013
Messages
16,607
i'm going to drop out as I can see no way of helping you.

We are 24 posts in for something which is really very simple. I don't know why you are struggling. you have not been consistent in what you require and you have been given multiple solutions and sources of information.

good luck with your project
 

Micron

AWF VIP
Local time
Today, 11:12
Joined
Oct 20, 2018
Messages
3,478
The fact that you don't see sourceobject in intellisense doesn't mean much. Plenty of properties are not revealed there, but can be found in online documentation or the object browser. If they exist and have been properly invoked they will work regardless. If you want the sourceobject property value for "subform2" where you have

MainForm>subform1>subform2 then this should work:

Code:
Forms!YourFormName.ParentSubformControlName.Form.childSubformControlName.Sourceobject
The fact that Access names a control the same name as an object that it is bound to is of little consequence here beyond serving only to confuse. If you place that name in the proper part of the syntax, Access will figure out that "subForm1" is the control when it needs to and the fact that the form contained within has the same name it is irrelevant. What matters is that the name you pass to the hierarchy of a reference is valid for that part of the reference. Note that I would not say the same thing for where a field and a control has the same name.

It may very well be that you don't see what you expect in intellisense because what comes before what you're looking for has not been properly constructed.
 
Last edited:

MajP

You've got your good things, and you've got mine.
Local time
Today, 11:12
Joined
May 21, 2018
Messages
8,527
The fact that you don't see sourceobject in intellisense doesn't mean much.
I disagree with that statement as it relates to this problem. In this case, it means everything. Recordsource and sourceobject are always properly exposed by intellisense.

The absolute only way that sourceobject does not appear in intellisense and recordsource does, is that the OP is not referencing a subform control but is referencing a form object. This has been previously stated correctly in this thread by others.

If a proper reference to a subform control is made then sourceobject will be available and not recordsource.
Me.subformControlName.SourceObject = "NameOfForm"

If a proper reference to a form inside a subform control is made then recordsource will be available and not sourceobject.
Me.SubformControlName.Form.Recordsource = "NameOfTableOrQuery"
 

Micron

AWF VIP
Local time
Today, 11:12
Joined
Oct 20, 2018
Messages
3,478
I disagree with that statement as it relates to this problem.
Can't disagree with that. My message was poorly written and my last sentence didn't really clarify that point:
It may very well be that you don't see what you expect in intellisense because what comes before what you're looking for has not been properly constructed.
which was supposed to mean the chain of references was not correct, which certainly would be the case if one was attempting to get the source object of something that doesn't have one. I was trying to explain that missing properties in intellisense does not mean they don't exist.
 

Users who are viewing this thread

Top Bottom