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 June 1st, 2006, 08:48 PM
Registered User
 
Join Date: Jun 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Open a Parameterised Query to screen using code

What I want to do is pass a paramater into a paramaterised query then open the query to screen without having the promt appear
And or do the same with a report based on a paramatersied query, again without the promt appearing....

The query would be something like

PARAMETER [dPeriodID] IEEEDouble;
SELECT * FROM Data Where PeriodID = [dPeriodID]


Public Sub OpenParameterQuery()
    Dim qdf As DAO.QueryDef

Set qdf = DBEngine(0)(0).QueryDefs("QueryName")
    qdf("[PeriodID]") = 12


DoCmd.OpenQuery "QueryName"


End Sub


What I want to do is more complex than this, I have written this as an example, so changing the SQL is not an option
Any ideas?


 
Old June 2nd, 2006, 07:35 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I am not sure wha this is that you have written. How is the query being opened? If from a form, and the parameter appears in a control on a form, then you can create a SELECT query, and in the PeriodID field, put this in the Criteria in Design view:

[Forms]![frmYourForm].[dPeriodID]

Alternatively, you can pass a number with this syntax:

sLink = "[PeriodID] = " & dPeriodID

And a string with:

sLink = "[PeriodID] = " & "'" & dPeriodID & "'"

Then in the WHERE section of the OpenQuery command:

DoCmd.OpenQuery "QueryName", , sLink

Does this help?





mmcdonal
 
Old June 5th, 2006, 05:46 PM
Registered User
 
Join Date: Jun 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Thanks.

I guess I'll have to do something with a hidden open form.

Dean





Similar Threads
Thread Thread Starter Forum Replies Last Post
splash screen query demac43 Visual Basic 2005 Basics 2 May 15th, 2007 03:20 PM
Open a PDF as top screen JeffGirard Access VBA 1 January 30th, 2007 08:28 PM
Need code to open the printer dialog screen donrafeal Access VBA 1 June 13th, 2006 01:35 PM
Parameterised Access Query in javascript howbadboy Javascript 2 February 26th, 2005 12:39 PM
How do I open a Web page in full screen esilverb Javascript How-To 3 June 24th, 2003 09:46 AM





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