Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,173
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
pass parameter to access query Bill Manville Links and Linking in Excel 4 May 1st 23 03:45 AM
Pass date parameter into MS Query Richard Edwards Excel Discussion (Misc queries) 2 June 20th 08 11:43 AM
Is it possible to pass a parameter into IN operator in Query? DennisS Excel Discussion (Misc queries) 0 June 26th 07 09:27 AM
How to pass a workshhet name as a parameter into a subroutine ? yigalb Excel Discussion (Misc queries) 4 January 9th 05 10:28 AM
Pass Parameter to Access Query Al Excel Programming 3 April 29th 04 10:15 AM


All times are GMT +1. The time now is 03:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"