Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
tod tod is offline
external usenet poster
 
Posts: 114
Default Opens Workbook and not Query

I have the following code:

With cm
.ActiveConnection = cn
'Where VariableForQueryName is the name of the query
exactly as it appears in my Access database
..CommandText = VariableForQueryName
.CommandType = adCmdStoredProc
'OtherInputField is the name of the field in the query.
Set pm1 = .CreateParameter(OtherInputField,
adInteger, adParamInput)
.Parameters.Append pm1
'ReportMonth is a variable that holds the month number as
an integer
.Parameters(OtherInputField) = ReportMonth
Set pm2 = .CreateParameter(OtherInputField,
adInteger, adParamInput)
.Parameters.Append pm2
.Parameters(OtherInputField) = ReportYear
End With

rs.Open cm

So what this does is create two parameters, one for month
and one for year and passes those parameters to my Access
query into a field that prompts for those two values. It
then returns the Recordset for me to work with. In the
Access database, the above-mentioned query includes a an
access table that is linked to an Excel workbook.

The problem is that this statement:

rs.Open cm


is opening the workbook that is for the linked table
instead of returning the recordset from the query.

If I run the query myself it works fine. I also use the
same code for other queries and it works fine for them.

Why would the workbook open?

tod
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
when opening an Excel Workbook, another blank workbook also opens spmu Excel Discussion (Misc queries) 0 October 12th 07 01:46 PM
Excel Sheets Opens Itself Again After ADO Query ! Please Help It's Urgent ! Nader[_2_] Excel Discussion (Misc queries) 0 August 28th 07 09:39 AM
Query is lost when Excel s/sheet opens dlb Excel Discussion (Misc queries) 0 January 24th 07 07:53 PM
Personal workbook opens when Excel opens SheriTingle Excel Discussion (Misc queries) 2 March 30th 05 12:22 AM
Winn98SE, Excel2000: ODBC query opens the source workbook Arvi Laanemets Excel Discussion (Misc queries) 9 March 10th 05 06:32 AM


All times are GMT +1. The time now is 04:46 PM.

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

About Us

"It's about Microsoft Excel"