ACC2: Help Topic "Converting Code" Sample Code IncorrectLast reviewed: May 14, 1997Article ID: Q114732 |
The information in this article applies to:
SYMPTOMSAdvanced: Requires expert coding, interoperability, and multiuser skills. The sample code for running a pass-through query in the Microsoft Access version 2.0 Help system topic "Examples of Converting Code to Version 2.0" is not correct. If you run this code, you will receive one of the following error messages:
Object variable not set or Name not found in this collection -or- Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE' RESOLUTIONThe incorrect sample code is as follows:
' Given open Database object MyDB. Dim Q As QueryDef Set Q = MyDB.CreateQueryDef("MYODBCQuery") Q.SQL = "Exec My_Stored_Procedure" Q.Connect = "ODBC; DSN=MyServer; UID=sa; PWD=hithere; DATABASE=pubs" Q.ReturnsRows = True Dim R As Recordset Set R = Q.OpenRecordset()To correct the code, make the following two changes:
' Given open Database object MyDB. Dim Q As QueryDef Set Q = MyDB.CreateQueryDef("MYODBCQuery") Q.Connect = "ODBC; DSN=MyServer; UID=sa; PWD=hithere; DATABASE=pubs" Q.SQL = "Exec My_Stored_Procedure" Q.ReturnsRecords = True Dim R As Recordset Set R = Q.OpenRecordset() STATUSThis problem no longer occurs in Microsoft Access version 7.0.
REFERENCESFor more examples of converting code to version 2.0, search for "converting code," and then "Examples of Converting Code to Version 2.0" using the Microsoft Access Help menu.
|
Additional query words: documentation
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |