set parameter to a query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following code that retrieve data from an access query
but since the access query has a parameter call id it is complaning that I
do not pass the value of the parameter.

(SELECT Table1.version, Table1.id, *
FROM Table1
WHERE (((Table1.id)=[ id ]))
ORDER BY Table1.version DESC;)


How do I Add to the below the value for my parameter id?


Dim Connection As ADODB.Connection
Set Connection = New ADODB.Connection
Connection.ConnectionString = ConnectionString
Connection.Open
Dim Recordset As Recordset
Dim RowsAffected As Long

Set Recordset = Connection.Execute("[Query1]", RowsAffected,
CommandTypeEnum.adCmdTable)

Thanks, Mark
 
I have the following code that retrieve data from an access query
but since the access query has a parameter call id it is complaning that I
do not pass the value of the parameter.

(SELECT Table1.version, Table1.id, *
FROM Table1
WHERE (((Table1.id)=[ id ]))
ORDER BY Table1.version DESC;)

You can't use the same name for the parameter as for the field that you're
searching (or any other field!).

Try

WHERE (((Table1.id) = [Enter ID]))

so that it is unambiguous which is which.

John W. Vinson [MVP]
 
Back
Top