pass parameter to Query

G

Guest

I have the following code that retieve 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
Dim i As Integer
Dim Cmd As Object

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

Thanks, Mark
 
G

Guest

Because there are a lot of stored procedures and I do not want to have to
rewrite them all.

Mike said:
If you know the SQL why not just query it in excel instead of running access
query?

mark said:
I have the following code that retieve 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
Dim i As Integer
Dim Cmd As Object

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

Thanks, Mark
 

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