set parameter to a query

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
 
J

John W. Vinson

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]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top