Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VB Access report Automation

2 views
Skip to first unread message

patrickpakes

unread,
Dec 5, 2002, 11:08:43 AM12/5/02
to

Help,
I am using vb6 to launch an MS Access project (adp) within the
project there is a report that is bound to stored procedure. How
do I pass parameters to the report's stored procedure and stop it
from prompting for them?
I know there is a property InputParameters but I can't seem to get it to
work in my scenario.

Set objAccess = CreateObject("Access.Application")
With objAccess
.OpenAccessProject filepath:=dbName
'InputParameters here???
.DoCmd.OpenReport "testx, acViewPreview
end with

--
Posted via http://dbforums.com

Norman Yuan

unread,
Dec 5, 2002, 4:57:55 PM12/5/02
to
I had similar problem. My first try was as following:

(to set report's property (InpuParameters), the report must be loaded.
So...)

Dim rpt As Access.Report
Dim objAccess As Access.Application
Set objAcceass=CreateObject(....)
With objAccess
.OpenAccessProject "c:\....\xxx.adp"
'You need open report before referring to it
DoCmd.OpenReport "MyReport",acViewDesign
Set rpt=.Reports("MyReport")
rpt.InputParameters="@Param1 Int=" & intValue" & ",@Param2 VarChar=" &
strValue & ",@......."
'Now you open the reprot for previewing or printing
DoCmd.OpenReport "MyReport", acViewPreview
End With

This is supposed to work, but somehow Access still pops up Parameter input
box

My final solution to the problem in my project:

1. Bind report's InputParameters property to control(s) on a form, that is,
in report's properties window, locate InputParameters item, type in
something like: @Param1 int=Forms!ParamForm!txtParam1,@Param2
VarChar=Forms!ParamForm!txtParam2...

2. Create a form, name it as "ParamForm", and put some controls on it (i use
TextBox) to hold parameter value

3. Before you open report, you first open the form (ParamForm) and pass your
parameters from your program to the form. Then you open the report. Now the
report should be able to pass the paramenter to stored procedure. You can
set the form's Visible property to False and close it after the report is
opened on close it in Report_Close() event handler. Code looks like:

Dim frm As Access.Form

With objAccess
.OpenAccessProject "c:\....\xxx.adp"

'You open the parameter form first to hold your parameters
DoCmd.OpenForm "ParamForm",acNormal

Set frm=.Forms("ParamFormt")
frm.Visible=False
frm!txtParam1=intValue
frm!txtParam2=strValue
frm!txtParam3=.......

'Now you open the reprot for previewing or printing
DoCmd.OpenReport "MyReport", acViewPreview

'Close the form
DoCmd.Close acForm, "ParamForm", acSaveNo

End With

HTH


"patrickpakes" <mem...@dbforums.com> wrote in message
news:2128624.1...@dbforums.com...

0 new messages