English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

im working on a system which required a specific report with user key-in for the report, for example the user wants the report for computer usage on 15 jan, he'll type in 15 jan in a dialog box and the report will displayed the computer log on 15 jan only. since i cant generate report using VB 6.0, i used report from access. and its exactly as i want. and now all is settled if i can find a way to call the report from access. or else there must be a way to do that using VB 6.0 i just dont know how.

2007-02-13 13:14:03 · 1 answers · asked by farina m 4 in Computers & Internet Programming & Design

1 answers

I don't understand why you did not use the report generator built into VB6. It works in a similar fashion to the access report but entirely from within VB6.

Create a DataEnvironment and create your queries. Then Add a Data Report and bind to the query in the Data Environment. The report designer even supports drag and drop.

But IF you really want to Call Access and run a report...you can try running the report using automation

Sub PrintAccessReport(dbname As String, rptname As String, _
preview As Boolean)
Dim objAccess As Object
On Error GoTo PrintAccessReport_ErrHandler
Set objAccess = CreateObject("Access.Application")
With objAccess
.OpenCurrentDatabase filepath:=dbname
If preview Then 'Preview report on screen.
.Visible = True
.DoCmd.OpenReport reportname:=rptname, _
view:=Access.acPreview
Else 'Print report to printer.
.DoCmd.OpenReport reportname:=rptname, _
view:=Access.acNormal
DoEvents 'Allow report to be sent to printer.
End If
End With
Set objAccess = Nothing
Exit Sub
PrintAccessReport_ErrHandler:
MsgBox Error$(), , "Print Access Report"
End Sub

2007-02-13 14:34:02 · answer #1 · answered by MarkG 7 · 0 0

fedest.com, questions and answers