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
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 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.
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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.