[AccessD] Reporting Question

Michael R Mattys michael.mattys at adelphia.net
Thu Jan 15 20:09:04 CST 2004


Robert,

I copied the tables (Products and Suppliers) from Northwind
to my database and opened the report in design view. Then
I set the recordsource to Products1 in the currentdb.

Sub DisplayReport()
    Dim appAccess As Application, rpt As Report
    Const strConPathToSamples = "C:\Program Files\Microsoft
Office\Office\Samples\Northwind.mdb"
    Dim strDB As String
    ' Initialize string to database path.
    strDB = strConPathToSamples
    ' Create new instance of Microsoft Access.
    Set appAccess = CreateObject("Access.Application.8")
    ' Open database in Microsoft Access window.
    appAccess.OpenCurrentDatabase strDB
    ' Open Orders form.
    appAccess.DoCmd.OpenReport "Alphabetical List of Products", acViewDesign
    Set rpt = appAccess.REPORTS("Alphabetical List of Products")
    rpt.RecordSource = "Select * From Products1 in '" & CurrentDb.Name & "'"
    appAccess.DoCmd.OpenReport "Alphabetical List of Products",
acViewPreview
    appAccess.Visible = True
    Set rpt = Nothing
    Set appAccess = Nothing
End Sub

Michael R. Mattys
Try MattysMapLib for MapPoint at
www.mattysconsulting.com



More information about the AccessD mailing list