Solved

What command button code will cause this procedure to run.

Posted on 2000-03-02
3
136 Views
Last Modified: 2011-08-18

What command button code will cause this procedure to run. Specifically, I don't understand what the "subject" parameter means.

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:=stsarkis.mdb
        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
Comment
Question by:dtmaurer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 4

Accepted Solution

by:
abaldwin earned 50 total points
ID: 2578395
The parameter "Subject" appears to be the name of the report to open.  When using this sub routine you need to pass a string containing the name of the access report you wish to open.

this appears to be a sub routine called by some other procedure.  It has no event associated with it (i.e. cmdPrint_Click)  this appears to be a "Print Module" if you will.  When different reports are chosen (proablably one button per report) then that button sets the string to the report name desired and calls this sub to actually open the report.

Does that help?
Andy
0
 
LVL 2

Expert Comment

by:Glen Richmond
ID: 2578528
abaldwin explains it well..

an example of its code usage is..

Sub cmdPrintInvoice_Click()
         RunReport "Invoice",True
End Sub

Sub cmdPrintOrder_Click()
         RunReport "Order",True
End Sub

this will preview the report
leave off the True (optional preview) to print direct.




0
 

Author Comment

by:dtmaurer
ID: 2580186
Thanks, Guys!. Works great!

Dave
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question