Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

What command button code will cause this procedure to run.

Posted on 2000-03-02
3
Medium Priority
?
138 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 200 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

688 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