How to pass parameters to Access report via Automation

D

Dean Slindee

I would like to pass multiple parameters from a VB.NET application to an
existing Access 2003 application's reports (essentially using Access as a
report writer where the reports already exist).
The reports' datasource is a stored procedure with multiple @parameters.

This code works where the report requires no parameter:
Dim strAccessDBPath As String
Dim booReturn As Boolean = False
strReportName = "rptCMOTeam1"
strAccessDBPath = "W:\Clinical Services Database\Clinical
Services.ade"
booReturn = OLEPreviewReport(strDB, strReportName)

A Microsoft example shows using a single parameter:
booReturn = OLEPreviewReport(strDB, strReportName),
strWhere:="OrderId = 10251")

Would "OrderId" feed into a @OrderID parameter in a stored procedure, or is
there another way to replace the strWhere clause to feed the @parameters in
the stored procedure?

Thanks,
Dean Slindee
 
S

Steve Schroeder

This may be possible, I don't know. You could write data to a table in
Access and have the report use the table are criteria for the report...but,
frankly I think this is a bad idea.

Let Access be Access and VB.Net be VB.Net. The is just my opnion however.
 
T

Tim Riley

I believe the strWhere part below is the same as the box within Access
where you put the parameter.

A Microsoft example shows using a single parameter:
booReturn = OLEPreviewReport(strDB, strReportName),
strWhere:="OrderId = 10251")

Saying that, I believe something like this would work:
strWhere:="@orderID = value, @param2 = value, @param3 = value, @param4 =
value"

Try what I did above out. If it does not work with the @ signs, remove
and try again. Let us know.

Thanks,

Rocco
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top