Access XP Automation with VB 2003 - Print Report - Pass Parameter

S

Stuart

Hello All -

I am using VB.NET 2003 to automate Access XP. Specifically, I am trying to
print out an Access report. The report I want to print is based on a
parameterized query:

PARAMETERS [the code] Long;
SELECT * FROM [Absence Codes]
WHERE AbsenceCode = [the code];

I found an article in the MS KB entitled "HOW TO: Automate Microsoft Access
From Visual Basic .NET" [1] which provided an excellent start. When I click
the "Go!" button, Access presents me with a parameter input box for "[the
code]" and
everything works as expected.

However, I don't want any parameter input boxes popping up; I want to
provide the
parameter programmatically, presumably in my "DoCmd.OpenReport" call. This
should be a piece of cake,
but I can't seem to get it. Here's my OpenReport [2] call:

oAccess.DoCmd.OpenReport(sReport, , , "[the code] = 1")

The parameter input box still pops up. I don't get it. I've tried every
variation I can dream up.

Can anyone please provide some guidance here?

Thanks,

Stuart Laughlin
http://www.bistrotech.net

[1] http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q317113&#2

[2] The "OpenReport" method accepts the following arguments; all but the
first are optional:
ReportName
View
FilterName
WhereCondition
WindowMode
OpenArgs
 
C

Cindy Meister -WordMVP-

Hi Stuart,

Base your report on a non-parameter query, then change the QueryDef (using
DAO) before executing the report. OR change the report's Source to be an SQL
string instead of a saved query and change that property before executing the
report.
I am using VB.NET 2003 to automate Access XP. Specifically, I am trying to
print out an Access report. The report I want to print is based on a
parameterized query:

PARAMETERS [the code] Long;
SELECT * FROM [Absence Codes]
WHERE AbsenceCode = [the code];

I found an article in the MS KB entitled "HOW TO: Automate Microsoft Access
From Visual Basic .NET" [1] which provided an excellent start. When I click
the "Go!" button, Access presents me with a parameter input box for "[the
code]" and
everything works as expected.

However, I don't want any parameter input boxes popping up; I want to
provide the
parameter programmatically, presumably in my "DoCmd.OpenReport" call. This
should be a piece of cake,
but I can't seem to get it. Here's my OpenReport [2] call:

oAccess.DoCmd.OpenReport(sReport, , , "[the code] = 1")

The parameter input box still pops up. I don't get it. I've tried every
variation I can dream up.

Can anyone please provide some guidance here?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan 24 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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