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 February 25th, 2005, 06:48 AM
Authorized User
 
Join Date: Dec 2004
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default Passing a varibale into a query

Hello

Does anyone know if it is possible to pass the value of a variable to a pre-defined query? If so how?

Cheers



Cheers
Tony
__________________
Cheers
Tony
 
Old February 25th, 2005, 07:00 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

One way to do this is to have a form open with a field that contains the value. Then just point to that field using something like the following for the value in your query.

[Forms]![_frmName_].[_fldname_]

The form doesn't have to be visible, but it does have to be open.

If the user has to input the value each time the query runs you can use a syntax similar to...

[Please enter _whatever_]

And a third option is to use a function in your code.

Global xxxValueForQuery as ...

Public Function ValueForQuery () as ...
ValueForQuery = xxxValueForQuery
End Function

Before calling the query set xxxValueForQuery. In the query use ValueForQuery() wherever you need it.

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org
 
Old February 25th, 2005, 08:19 AM
Authorized User
 
Join Date: Dec 2004
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Great,cheers for that.

Cheers
Tony





Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing Value Query rsm42 ASP.NET 1.0 and 1.1 Basics 2 July 2nd, 2007 11:49 AM
Tomcat session varibale ibozo Servlets 2 June 4th, 2007 05:48 AM
Passing Variable to Query dalezjc Classic ASP Databases 2 November 14th, 2006 03:27 PM
Query Regarding passing Of Values gadhiav ASP.NET 1.0 and 1.1 Basics 5 July 16th, 2004 05:49 AM
passing input to a query mirage Access 3 October 23rd, 2003 08:43 AM





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