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.
SELECT * FROM table1 WHERE table1.ID = [pID], you could then doDebug.Print Replace(qd.SQL, "[pID]", qd.Parameters("pID").Value)I don't know any other way to get what you want.QueryDefsobject. It isn't an answer that I really NEED, more so something that just piqued my interested from another question. Thanks anyway!