|
-
Mar 13th, 2000, 03:31 PM
#1
Thread Starter
Hyperactive Member
Dear VB users,
My Access database is consisting a report.
Is it possible to print this report in VB5?
If yes: what is the syntax of the command?
Nice regards,
Michelle.
-
Mar 13th, 2000, 06:42 PM
#2
New Member
It is possible to print or preview an access report from vb. I included an example code below(vb_ShowReport). All you need to do, is to replace phrases in brackets <>. The code assumes following:
database has a module which has a sub called ShowReport.
I hope this solves your problem!
Public Sub ShowReport(ByVal rptName As String, ByVal filter As String)
DoCmd.OpenReport rptName, acViewPreview, "", filter
DoCmd.Maximize
End Sub
Private Sub vb_ShowReport(ByVal reportName As String, ByVal filter As String)
Dim myAccess As Access.Application
Dim start As Double
Dim tmpLng As Long
On Error Resume Next
Err = 0
Set myAccess = New Access.Application
' Full access installed
If Err = 0 Then
myAccess.OpenCurrentDatabase "<databasename>"
myAccess.Run "ShowReport", reportName, filter
myAccess.Visible = True
' Only runtime installed
Else
tmpLng = Shell("<MSAccess.exe> <databasename>", vbMaximizedFocus)
If tmpLng <> 0 Then
start = Timer
Do
Err = 0
DoEvents
Set myAccess = GetObject("<databasename>")
If Timer - start > 7 Then
Exit Do
End If
Loop While Err <> 0
myAccess.Run "ShowReport", reportName, filter
End If
End If
End Sub
ps. You need to add a reference to Access x.0 object library to your VB-project
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|