Users Online

· Guests Online: 15

· Members Online: 0

· Total Members: 188
· Newest Member: meenachowdary055

Forum Threads

Newest Threads
No Threads created
Hottest Threads
No Threads created

Latest Articles

Open Parameter queries from code

Open Parameter queries from code

 

Open Parameter queries from code

Author(s)
Dev Ashish

(Q) How do I open a Parameter Query from code?

(A) In order to open parametric queries, you need to explicitly pass each parameter by using the Parameters property before opening a recordset based on the query.

For example, in the following code snippet, the Query "Qry1" has two parameters; namely, [Please enter Code:] and [Please enter city:].

'************ Code Start ****************
Dim db As Database 'current database
Dim rs As Recordset 'holds query resultset
Dim qdfParmQry As QueryDef 'the actual query object
    Set db = CurrentDb()
    Set qdfParmQry = db.QueryDefs("Qry1")
    qdfParmQry("Please Enter Code:") = 3

    ' or try this alternate method
    ' to pass the parameter
   
    qdfParmQry![Please Enter City:] = "New York"
    Set rs = qdfParmQry.OpenRecordset()
'************** Code End ***************

Comments

No Comments have been Posted.

Post Comment

Please Login to Post a Comment.

Ratings

Rating is available to Members only.

Please login or register to vote.

No Ratings have been Posted.
Render time: 0.69 seconds
10,800,147 unique visits