Click to See Complete Forum and Search --> : Access97....need help!!
Hallo
I have to alter an existing Access App. One of my questions (at the moment) is How do I send parameters to a report from my own dialog form? I know how to invoke it through access ( the parameters tha is), but I need to display info in a Combo box for the user to select the parameters...and not only typing it in.
Please help on this one!!
Thanx
paulw
Nov 24th, 2000, 08:35 AM
What is the code you are using at the moment? Post it up and I'll see what we can do...
P.
Hi
Here is the code that opens the report.
' Open a report.
Case conCmdOpenReport
DoCmd.OpenReport rst![Argument], acPreview
It is part of a Select Case statement. They invoked the parameter from the table itself with [Type EmployeeNumber]. There are no further code except the SQL Statement.
Hope this is what you were looking for. Please let me know if you need anything else from the App.
Thanx
paulw
Nov 27th, 2000, 05:15 AM
When you say 'parameters' what precisely do you mean?
Are you using a parameterised query to filter the report or what?
If the query is a parameter query I would use a modal form to return user information and then build a SQL statement.
Let me have a few more details - i.e. what SQL are you using etc.
Cheers,
P.
Sorry for the vagueness but here it is:
I would like to capture parameters (filter) on a dialog box. I pass this parameters to a SQL statement where I generate the query result for a specific report.
I know how to do this in VB but this is new to me in Access. I do not know how to construct a query here where I pass one or more than one parameters to a query.
Please let me know whether this is still unclear.
Thanx
paulw
Nov 27th, 2000, 07:26 AM
It is easiest to do it in code in Access as well. The code should be pretty well identical in both environments. Simply construct the SQL statement, including your variables and either set the Reports source to that SQL statement or use it as a filter in the OpenReport method.
If you want to use a pre-defined query (which is less flexible), then you would access its Parameters collection.
I hope that's clear enough?
P.
Hallo
How do I allocate this query in code to a Report at runtime? In VB I use Data Environment and use the "?" to show a parameter must be received for my query. On OpenReport I only see examples where 1 parameter is passed...
Am I understanding it incorrectly?? Or should I define a query and using the filter of OpenReport to specify the where clause?? How do you handle 2 or more parameters then ask asked above??
I know....I'm clueless!
paulw
Nov 27th, 2000, 10:24 AM
At the end of the day, you are trying to pass a filtered set of data to a report. You can either send a complete set of data to the report and filter it with the WHERE clause of OpenReport or you can set up the source query to return the filtered set.
If you want to set up the query as parameterised (which will produce an input box at run time) you can fill these in using the parameters collection (check the help). However, since you are collecting the parameters up front form your VB app, it is easier to create a fully qualified SQL query.
i.e.
Report "rpt" based on MyTable
DoCmd OpenReport "rpt",,,"Name = 'Me'"
or
Report "rpt" based on MyQuery
Parameterised Query (MyQuery)
SELECT * FROM MyTable WHERE ...
Name = [Get Name]
i.e. Query prompts for Name
DoCmd OpenReport "rpt" - picks up paremeterised query by default...
or (best)
MySQL = "SELECT * FROM MyTable WHERE Name = " & Me.txtName
' picks up name from text box on the form...
Set rpt.Recordsource = MySQL
DoCmd OpenReport "rpt"
Clearer?
P.
Thanx for your help, I appreciate it.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.