dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
May 13, 2002

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Execute Parametrized QueryDefs Simultaneously in DAO


In Microsoft Access, you can execute a parameterized query that uses other parameterized queries, as long as their parameter names are the same. Save these queries in an Access database: "QueryOne"
 
PARAMETERS MyDate DateTime;
SELECT Date1 FROM TableOne WHERE Date1>MyDate;
"QueryTwo"
PARAMETERS MyDate DateTime;
SELECT Date1 FROM TableTwo WHERE Date1>MyDate;
"QueryUnion"
PARAMETERS MyDate DateTime;
SELECT * FROM QueryOne
UNION
SELECT * FROM QueryTwo;

You can execute QueryUnion from VB code by passing the MyDate parameter. This example is for DAO 3.5:
 
Sub ExecuteQuery()
Dim db As Database
Dim rs As Recordset
Dim qd As QueryDef
Set db = OpenDatabase("<database name>")
Set qd = db.QueryDefs("QueryUnion")
qd.Parameters(0).Value = CDate("3/1/00")
Set rs = qd.OpenRecordset(dbOpenSnapshot)
' <.....>
rs.Close
db.Close
End Sub
Pavel Maksimuk
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date