Viewing SQL Statements

gothung

New Member
Joined
Jun 3, 2002
Messages
32
When I use the filter by form option to filter my query, it creates an SQL statement to tell the query what to use as filters. Is there anyway to show the SQL results in a text box in a report. An example SQL Statement looks like this:

SELECT *
FROM [Parts 2 Query]
WHERE ((([Parts 2 Query].Dept)=400) AND (([Parts 2 Query].Geography)="UNDERHOOD"));

The parts in Bold are the ones that I want to read into my report.

Can anybody help me with this?
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
do a search in help for "Print the criteria for a report in the report header" and see if this is what you need.
(found in A2K)

HTh

Peter
 
Upvote 0
I looked into the help file and tried the suggestion that it gave me, the only problem is that you have to type in what it says in the text boxes. I want it to read in automatically from the SQL statement in the query. I purposly did not use this feature, because I wanted users to make their selections of criteria from drop down boxes in a form, to make it easier for them. With all that I get my data to read in perfectly, I would just like to have that criteria automatically read in, and since I am using the filter by form option, I figured that the only way to retrieve that would be through the SQl Statement. Please correct me if I am wrong, or if you have any other options to try.

Thanks

Dan
 
Upvote 0
You can link fields in your report directly to the dropdown boxes in the form to get the values from them.

Peter
 
Upvote 0
Because I am using the "filter by Form" option to make the selections, it requires me to turn off the the filter before I can close the form. When I open my report all I see in those text boxes are: #Name?
 
Upvote 0
Don't close the form before running the report -- hide it instead, and then close it when the report closes (use the Close event of the report). That way, you have full access to the field values in the form.

Denis
 
Upvote 0
Even if I minimize the window without closing it, it still does not put those values into the report.
 
Upvote 0

Forum statistics

Threads
1,221,566
Messages
6,160,525
Members
451,655
Latest member
rugubara

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top