-
I search the Q and A but can not find a old question that helps. I learn how to use the Docmd.Openreport to print out a Access Report. But I also want to view it the same way you can crystal report thourgh the viewer. Is the any way I can ope the Access report in Access thourgh VB. Does some body have the code.
-
The code below will print to the default printer, but I have figured out how to print preview it yet, if you do, please let me know how you did it.
Hope it works for you. :-)
============================================================
Private Sub Command1_Click() 'This code is trial code for printing reports.
Dim oAccess As Object
' This was the toughest part. Getting the db name and location right! (and drive) :)
Const gDBName = "C:\My Documents\dbMine.mdb"
On Error GoTo Command1_Click_Error
Screen.MousePointer = vbHourglass
Set oAccess = CreateObject("Access.Application")
With oAccess
.OpenCurrentDatabase (gDBName)
' Here I changed to Preview report, "acViewPreview".
' Lookup OpenReport in Access Help, only trouble is it doesn't work :(
.DoCmd.OpenReport "rptTest", acViewPreview
End With
Set oAccess = Nothing
Screen.MousePointer = vbNormal
Exit Sub
Command1_Click_Error:
MsgBox "Error: " & Err & " - " & Error
End
End Sub
-