Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.
Open a Form or Report in an External Database
It is possible to open an external database and display a form or report. This example shows how to display a report.
Sub DisplayExternalReport() Dim strDB Dim appAccess As Access.Application ' Initialize string to database path. strDB = "C:\Docs\LTD.mdb" ' Create new instance of Microsoft Access. Set appAccess = CreateObject("Access.Application") ' Open database in Microsoft Access window. appAccess.OpenCurrentDatabase strDB ' Open report. 'The next code line can easily be changed to 'appAccess.DoCmd.OpenForm "frmForm" 'You can even add a Where statement. appAccess.DoCmd.OpenReport "rptReport", acViewPreview appAccess.Visible = True appAccess.UserControl = True End Sub