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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report with Parameter

Status
Not open for further replies.

university1522

Programmer
Jun 12, 2004
2
CA
Hi Everybody,

Here I am trying to open a report, created in microsoft Access database. It is report created from parametric query and I want to set its (report's parameter) by code.Code used in given below. But I think my syntex is wrong and also could not find relevant code in Access help. If any body can guide me, where i am doing mistake? or does any body have code to open a report created from parametric query from AutoCAD VBA environment ?? Plesae help me i will be thankful.

access.DoCmd.OpenReport "CityOfficerQuery1", acViewPreview,, ["Enter ProjectID"].String = UserForm2.CmbBoxReportProjectID.List(UserForm2.CmbBoxReportProjectID.ListIndex)
 
Have you tried to instantiate the QueryDef object related to the report's underlaying query, and play with its Parameters collection ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi University 1522,
I may not understand your "criteria" argument in the "openReport" command. But, At first glance, your syntax is incorrect. I can't quite tell if you are attemptimg to concatenate an expression?
["Enter ProjectID"].String = UserForm2.CmbBoxReportProjectID.List(UserForm2.CmbBoxReportProjectID.ListIndex
I am going to assume;
"EnterProjectID" is a form
"String" is a field, to be compared
"UserForm2 is a form
"list" & "ListIndex" are fields to be concatenated, to produce the criteria
If so...
,,"EnterProjectID.String =" & UserForm2.List & UserForm2.ListIndex)

Hope this helps, good luck!
 
Does the cboBoxReportProjectID supply the criteria? One criterion right?
Sorry, it's like this;
DoCmd.OpenReport "CityOfficerQuery1", acViewPreview,, "tblName.Field = " & _
Forms!frmName.cboName

I believe the form must be open, that has the cboBox, that supplies the criterion..

If cboBox, is a string expression, as opposed to integer, then the "Where" statement must have double quotes.
"tblName.Field = """ & _
Forms!frmName.cboName & """"

Encore une fois, bonne chance!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top