How to pick up sourceobject from another form?

Newbie8

Banned
Local time
Today, 12:53
Joined
Jun 29, 2019
Messages
30
I am trying to do form_formb.sourceobject = "formb" but sourceobject not showing as an option.
 
I am trying to do form_formb.sourceobject = "formb" but sourceobject not showing as an option.

I don't think Forms have a source object? However, subform/subreport controls DO have a source object.





Sent from my Pixel 3a using Tapatalk
 
I don't think Forms have a source object? However, subform/subreport controls DO have a source object.





Sent from my Pixel 3a using Tapatalk


Yes it's for a subform.
 
The name is formb

My guess is you've run into one of the problems caused by Microsoft Access. When you create a subform on a main form you actually don't! The process of placing a form on another form causes MS Access to automatically create an intermediary control between your main form and subform. Think of it as a window on the main form in which you can see the subform. I call it a "subform window" it's actual name, the correct term for it is "subform/subreport" cControl. Now this control "DOES HAVE" a source object. Now let's get to the problem caused by Microsoft Access, the automatic default name for this subform subreport control is the name of the form that is contained within it. So I suspect you are looking at something which is called "formb" but it's not actually a form, it's a subform/subreport control.
 
More information about subforms on my website here:- Sub-Forms - I would recommend viewing the video headed:- "Adding Hobbies to a Student Database" first...
 
and what is the name of your subform control?
 
so the code would be

formb.sourceobject


if the code is not in the form that has your formb subform control see this link for referencing objects in other locations

I tried that method originally, and I get variable not defined.
 
I am trying to do this Me!Subform1.Form!Subform2.Form.RecordSource on the main form
 
change your ! to . - then you can use intellisense to make sure your path is correct
 
Your subform name is FormB and the subform control that contains it is also called FormB (not the best situation but is is what Access will automatically do)?
BUT
is the form you want to pass the reference to the same form that holds the subform (your post title only says 'another form')

AND

why does your latest post show syntax for a nested subform? That is, the expression you posted is for referencing a subform on a subform on a main form.
EDIT - forgot that you might have more luck using the expression builder in cases like this. It usually gets the syntax right as long as you use it correctly.
 
I have a mainform>subform1>subform2. The code will be placed in the mainform needs to pick up subform2. They are basically tables controlled by two combo box, that allows you to select how many rows you need. When in form mode it shows as tables, combo box 1 works perfectly because I address the source object for subform1. Now I am trying to address the sourceobject for combobox2. I want to display 2 tables in subform1, and table1 is on subform1, and table 2 is in subform2.
 
Last edited:
And why? What do you need to do with subsubform RecordSource?

I always give subform container control a name different from the object it holds, like ctrDetails.
 
The only problem I need help with picking up the source object for subform1. That's all I need help with, for someone it is not picking it up. Intellisense gives me the record source.
 
The control has the sourceobject which is the form.?

Code:
    Me.RecordSource = "qryEmails"
    Me.sfrmEmails.SourceObject = "cfrmEmails"
 
Newbie8 wrote
I am trying to do this Me!Subform1.Form!Subform2.Form.RecordSource on the main form


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
 
The only problem I need help with picking up the source object for subform1. That's all I need help with, for someone it is not picking it up. Intellisense gives me the record source.

The issue is as I mentioned earlier and as others have mentioned, is that MS Access gives your subform/subreport control the same name as the form within it.

I'm going to say that again, MS Access gives the subform/subreport control the same name as the form within it

You say:-

Intellisense gives me the record source...

This means you are looking at a form.

You are looking at the properties of a form.

"Source Object" is a property of a Subform/Subreport Control.

If intellisense gives you "Record Source", then that means you are looking at a "Form".

If you want "Source Object" then you need to look at a Subform/Subreport Control.

I can understand your confusion because of the stupid way Microsoft gives the Subform/Subreport Control the same name as the form which is located within it.


Sent from my Pixel 3a using Tapatalk
 

Users who are viewing this thread

Back
Top Bottom