Set objAccess = CreateObject("Access.Application")
With objAccess
.OpenAccessProject filepath:=dbName
'InputParameters here???
.DoCmd.OpenReport "testx, acViewPreview
end with
--
Posted via http://dbforums.com
(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...