Determine the query that feeds the form

Victor70

Registered User.
Local time
Today, 13:39
Joined
Nov 16, 2011
Messages
66
Hello,
My apologies for probably a very simple question.
I inherited various queries and forms. I sometimes need to slightly modify a form but cannot identify the query (table) that this form was built upon.
How do I go about determining this?
Thanks in advance.
 
Have a look in the form's Property Sheet for the Record Source property.
 
Thanks a lot for the prompt response
 
And in the form's Property Sheet the Record Source Property will be on the Data Tab.
 
note that you can get at this in code directly

simply msgbox(me.recordsource)

it is even read/write so you can change a form just by changing the record source. (me.recordsource = "some query name") useful if you have two different queries, depending on some external choice.
 
note that you can get at this in code directly

simply msgbox(me.recordsource)

it is even read/write so you can change a form just by changing the record source. (me.recordsource = "some query name") useful if you have two different queries, depending on some external choice.
I would doubt that Victor70 knows how to code or where to put the code :)
 
Thank you.

Is msgbox(me.recordsource) for immediate window?

It would not work until I changed me to specific Form name (msgbox(Form_Suppliers.recordsource)). Even if the form was open.

I had however problems with entering form or report names that had spaces in their names.
 
ME would not work in this statement msgbox(me.recordsource) when the form is open or in design view. Only have to indicate the name of the form to make it work.

How do I refer to the form labeled Quarterly Orders (space in between)?

Thanks again for assistance.
 
That was why I gave you the other syntax. For spaces:
Code:
?Msgbox(Forms![COLOR=Red][[/COLOR]FormName[COLOR=Red]][/COLOR].RecordSource)
The reaon why you should avoid spaces when naming a form or field.
 
I have been using the MS Access sample database (Northwind).

When I run msgbox(Forms![Form_Sales Analysis].recordsource) Access says that it can't find the form.

For names without spaces the syntax above did not work either - I used msgbox(Form_Products.recordsource) to get the source info.

Thank you.
:-(
 
Don't use Form_Sales Analysis. That's not the name of the form. That's the name of the form's class module.

Your form name is Sales Analysis.
 
I see said that blind man...

I used [Sales Analysis]. It allowed to run the code only when the form was open (as it was mentioned before).

And I received a blank window with just OK button on it. The form is actually a pivot table, and it should draw data from a table or a query.

Why am I not getting the data source for it?
 
Last edited:
Like mentioned in my first post, just look in the property of the form. If that's empty then the object is probably embedded or the object is inside a subform.
 
No problem. Have you found it?

Yes, I did. I have Access 2000 on the machine with the database. The only way I could extract the data source was through the code (could not find the necessary property sheet).

However, most of the forms contain, I guess, as you put it, embedded objects or are based upon several queries/tables (?) so I receive blank message for the record source.:(
 
Here it goes.

The code
Code:
msgbox(Forms![Form1].RecordSource)
returns blank message for the Form1, which is a pivot table based upon Orders table.

Thanks.
 

Attachments

Users who are viewing this thread

Back
Top Bottom