Access report though VB but only report?

If calling a report from Access, can only the report be shown and not the rest of the access file?
LVL 1
treyjeffAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
karlovaConnect With a Mentor Commented:
Try this code from
http://users.vnet.net/aje/visual_basic/vbar.html 


Public Const acPreview = 2
Public Const acNormal = 0

Public Sub RunReport(Subject As String, Optional Preview As Variant)
    Dim Access As Object
    If IsMissing(Preview) Then Preview = False
    Set Access = CreateObject("Access.Application")
    With Access
        .OpenCurrentDatabase filepath:=DB_NAME
        If Preview Then 'preview report on screen
            .Visible = True
            .DoCmd.OpenReport Subject, acPreview
        Else 'print report to printer
            .DoCmd.OpenReport Subject, acNormal
            DoEvents 'allow report to be sent to printer
        End If
    End With
    Set Access = Nothing
End Sub

0
 
psmith789Commented:
You could open the Access .MDB file from VB, with an AutoExec macro to open the report and hide the database window (and other interface elements).

Easier, though, might be to use the Data Report Designer built into VB6, if you are up to that version (don't know if 5 has it). Look for the subject 'Create a Data-Bound Report' in the help file and it will walk you through including the designer in your project and using it - much like the Access report builder.
0
 
treyjeffAuthor Commented:
This works great, just wondering how someone can preview the report first?
0
All Courses

From novice to tech pro — start learning today.