![]() |
pass parameter to Query
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 |
pass parameter to Query
If you know the SQL why not just query it in excel instead of running access
query? "mark" wrote: 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 |
pass parameter to Query
Because there are a lot of stored procedures and I do not want to have to
rewrite them all. "Mike" wrote: If you know the SQL why not just query it in excel instead of running access query? "mark" wrote: 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 |
pass parameter to Query
Mark
You cannot pass parameters in Access via ODBC and MSQuery...try putting the parameters in Excel (Paste url on one line) http://www.nickhodge.co.uk/gui/datam...C_Data_Queries -- HTH Nick Hodge Microsoft MVP - Excel Southampton, England DTHIS web: www.nickhodge.co.uk blog (non-tech): www.nickhodge.co.uk/blog/ "mark" wrote in message ... 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 |
All times are GMT +1. The time now is 11:59 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com