Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 28th, 2004, 07:46 AM
Registered User
 
Join Date: Apr 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I believe that all parameters passed to forms and reports in MS Projects that talk to SQL Server must be in the format:

paramater name (eg: @id)
parameter type (eg: int)
paramater value

so Me.InputParameters="@id int=45"

However, I am coming up with a problem on dates.

I have a form (whose data is based on a parameterised stored procedure) with a drop down list of dates (cmbMondays); I change the data shown in the form thus:

Me.InputParameters = "@wsdate smalldatetime=#" & Format(cmbMondays, "dd mmm yyyy") & "#"

The form changes data correctly.

However, I also have a report based on a parameterised stored procedures that should work the same way. I pass the form's InputParameters to the report in the OpenArgs section:

DoCmd.OpenReport stDocName, acPreview, , , , Me.InputParameters

In the report_open event, I have:

Me.InputParameters = Nz(Me.OpenArgs, "@wsdate datetime=#1 Jan 2004#")

The report does NOT change its data!!

I have tried all sort of varants of date format and it still does not procude the data!!

Any thoughts much appreciated!

CR
 
Old November 8th, 2004, 09:30 AM
Registered User
 
Join Date: Nov 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In Access 2000, at least, there is no openargs parameter available in the OpenReport method of the DoCmd object, as there is in the OpenForm method. Thus the only way to pass stored procedure parameters is to write them to the InputParameters property of the report. In my experience this has to be done *before* the Open event of the form is triggered. (Apparently the stored procedure executes before the code in the Open event.)

In an ADP you can open the report briefly in design mode to set the InputParameter property, but in an ADE the method described by Brian is the only way I've found to set the stored procedure parameters dynamically: i.e., set the InputParameters property of the report to take its value(s) from control(s) of an open form and put the desired parameter(s) in the control(s) before opening the report.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Access 2000 Read-Only Problem sanjna000 Access 1 May 15th, 2006 01:13 PM
Update problem in MS Access 2000 socoolbrewster Access 1 March 12th, 2004 07:09 PM
Access 2000 VBA problem dubs70 Access VBA 2 February 18th, 2004 11:38 AM
problem with access 2000 and datagrid Nmatheus VB How-To 1 October 27th, 2003 05:48 PM
Access 2000 VBA Ch 6 Reports form project Nelz BOOK: Beginning Access VBA 1 September 29th, 2003 09:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.