ACC95: Incorrect GetAccessReportList in "Building Applications"Last reviewed: August 28, 1997Article ID: Q150058 |
The information in this article applies to:
SYMPTOMSAdvanced: Requires expert coding, interoperability, and multiuser skills. The GetAccessReportList procedure on page 288 of the "Building Applications with Microsoft Access for Windows 95" manual causes the error "Object doesn't support this property or method." (run-time error 438)
CAUSEThis procedure refers to a variable called "dbs" but fails to declare and set this variable. Also, the "and" condition on the first If statement refers to "mdb" but should refer to "mda." Finally, the text argument of the AddItem method should be specified as a named argument.
RESOLUTIONThis article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to the "Building Applications with Microsoft Access for Windows 95" manual. The following steps show how to use the GetAccessReportList procedure in Microsoft Excel. The corrected GetAccessReportList procedure is included in these steps:
Alternative GetAccessReportList ProcedureBelow is a slightly faster version of the GetAccessReportList procedure:
Sub GetAccessReportList() Dim lstReports As list box Dim strDBName As String Dim intReport As Integer Dim docReports As Object Dim intCount As Integer Dim strDoc As String Set lstReports = DialogSheets(1).ListBoxes(1) Set objAccess = CreateObject("Access.Application.7") strDBName = DialogSheets(1).EditBoxes(1).Text If Right$(strDBName, 4) <> ".mdb" And _ Right$(strDBName, 4) <> ".mda" Then strDBName = strDBName & ".mdb" End If objAccess.OpenCurrentDatabase strDBName With objAccess.DBengine(0)(0) Set docReports = .Containers("Reports").Documents intCount = docReports.Count - 1 For intReport = 0 To intCount strDoc = docReports.Item(intReport).Name If Left$(strDoc, 4) <> "~TMP" Then lstReports.AddItem Text:=strDoc End If Next End With End Sub REFERENCESFor more information about using Microsoft Access as an OLE automation server, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q147816 TITLE : ACC: Using Microsoft Access as an OLE Automation Server Keywords : AutoGnrl kberrmsg kbole IntpOleA Technology : kbole Version : 7.0 Platform : WINDOWS Hardware : x86 Issue type : kbdocerr Solution Type : kbcode |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |