Newd
Newd

Reputation: 2185

View parameterized query's SQL after setting parameters

The problem: I am looking for a way to view a parameterized query's SQL after the parameters have been set in VBA.

What I have tried:

Public Function test()

    Dim db As DAO.Database
    Dim qd As DAO.QueryDef

    Set db = CurrentDb
    Set qd = db.QueryDefs![1Para]

    qd.Parameters("ID").Value = 5

    Debug.Print qd.SQL

    Call qd.Close

End Function

Actual output:

SELECT * FROM table1 WHERE table1.ID = [ID]

Desired output:

SELECT * FROM table1 WHERE table1.ID = 5

I have looked for this answer online for a while but turned up nothing. That may indicate that this isn't possible but I thought I would ask here just in case there is something I missed.

Upvotes: 3

Views: 263

Answers (1)

Newd
Newd

Reputation: 2185

The answer seems to be not really.

Upvotes: 1

Related Questions