Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
when opening an Excel Workbook, another blank workbook also opens | Excel Discussion (Misc queries) | |||
Excel Sheets Opens Itself Again After ADO Query ! Please Help It's Urgent ! | Excel Discussion (Misc queries) | |||
Query is lost when Excel s/sheet opens | Excel Discussion (Misc queries) | |||
Personal workbook opens when Excel opens | Excel Discussion (Misc queries) | |||
Winn98SE, Excel2000: ODBC query opens the source workbook | Excel Discussion (Misc queries) |