Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

open a report using a combo box

Status
Not open for further replies.

Carol63

Programmer
Nov 10, 2002
8
AU
i need to run a report based on information from a combo box.
The combo box is on a separate form.
i think i need to do something to the query from which the report gets its input.
it may even be a macro.
 
You can pass a parameter when you open the Form, or pass an argument that can be interrogated in the OnOpen Event of the report to build an SQL string for the record source.

example - passes a parm to be filter when report opens.
Dim WhereClause
WhereClause = " componentType = " & QUOTE & CBComponentType & QUOTE
DoCmd.OpenForm DocName, , , WhereClause

example - pass an argument.
Dim LinkCriteria, Docname
DocName = "myreport"
LinkCriteria = "myfiltercriteria"
DoCmd.OpenForm DocName, , , , , , LinkCriteria

OnOpen Event - in Report.
Dim sql1
if me.openarg = "myfilercriteria" then
sql1 = "select * from mytable where myfield = " & _
"myfiltercriteria"
end if

Me.RecordSource = sql1

 
thanks for your response. (a bit too complicated for me)
i have greated a form with a combo box on which shows a list of peoples name. I want the query to open this form.
[forms]![frmPUPrimaryAction]![combo0] does not open this form.
is the parameter incorrect.
 
I thought you wanted to run a report and pass the report the name from the combobox. I am not sure what you are asking.
 
i need to run a report based on information input through a form. form just has a list of names - this list of names comes from a query field.
i have seen it before as a parameter query.
when a user clicks on a button a pop up form appears - they select a name on from the combo box on the form and then the report is previewed with the name select on the pop up form.
i hope this is not too confusing.
i sure what i want to do is very simple but i am making a mountain out of a mole hill.
 
i have the report
i have the query
i have the form with the combo box
 
In the OnClick Event of the combobox put the code to open the report. I assume the query is the record source for the report.

example - passes a parm to be filter when report opens.
Dim WhereClause as string, QUOTE as string
QUOTE = chr(34)
WhereClause = " yourname = " & QUOTE & CBname & QUOTE
DoCmd.OpenForm "yourreport", , , WhereClause

CBname is the combobox name.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top