"the return" old DAO project

User avatar
sal21
PlatinumLounger
Posts: 4357
Joined: 26 Apr 2010, 17:36

"the return" old DAO project

Post by sal21 »

With this code i pass a param in a query on Access database:

Code: Select all

...
    Set QRY = DB.QueryDefs("ESTRAI")
        QRY.Parameters("[INIZIO]").Value = CDate(Me.DAL.Text)
        QRY.Parameters("[FINE]").Value = CDate(Me.AL.Text)
...
but i need to pass also the name of table into the param, possible?

In effect the name of of table is dinamic but the query is the same.

Note:
I just have a string var TABELLA="2013"

User avatar
HansV
Administrator
Posts: 78501
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: "the return" old DAO project

Post by HansV »

You cannot pass the name of the table in the Parameters property. You'd have to change the SQL property of the query:

Code: Select all

    Dim strSQL As String
    strSQL = "SELECT ..." ' can be assembled dynamically
    QRY.SQL = strSQL
Keep in mind that will modify the stored query. It might be better to open a recordset with a dynamically assembled SQL string.
Best wishes,
Hans