Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / November 2005

Tip: Looking for answers? Try searching our database.

WHERE f$

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JethroUK - 19 Nov 2005 13:01 GMT
How do i pass a global variable (as criteria) to a Query design/SQL?

The variable f$ will contain an sql where statement e.g. "[Enquired] Is Not
Null AND [Letter Sent] Is Null"

Works fine if i just copy/paste into the SQL statement, or criteria line in
design

But I have to pass it as a variable (it will change according to a form
filter)

It has to be part of a query design because this in turn is used by a
mail-merged letter
Rick Brandt - 19 Nov 2005 13:37 GMT
> How do i pass a global variable (as criteria) to a Query design/SQL?
>
[quoted text clipped - 9 lines]
> It has to be part of a query design because this in turn is used by a
> mail-merged letter

You'll have to use code to change the SQL property of the query on the fly prior
to running the merge.

CurrentDB.QueryDefs("QueryName").SQL = "Base SQL " &  f$

Signature

I don't check the Email account attached
to this message.     Send instead to...
RBrandt    at       Hunter      dot      com

JethroUK© - 19 Nov 2005 14:16 GMT
This has been paining me for weeks - Thankyou

> > How do i pass a global variable (as criteria) to a Query design/SQL?
> >
[quoted text clipped - 19 lines]
> to this message.     Send instead to...
> RBrandt    at       Hunter      dot      com
Pat Hartman(MVP) - 21 Nov 2005 05:35 GMT
You can create a function that returns the variable value:
Public Function YourFunc()
   YourFunc = f$
End Function

Select .....
From ...
Where YourField = YourFunc();

I prefer to use hidden form rather than global variables.  So, in that case
the query would be:
Select ....
From ...
Where YourField = Forms!frmHidden!YourField;

> How do i pass a global variable (as criteria) to a Query design/SQL?
>
[quoted text clipped - 9 lines]
> It has to be part of a query design because this in turn is used by a
> mail-merged letter
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.