Solved

What command button code will cause this procedure to run.

Posted on 2000-03-02
3
133 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…

864 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now