Solved

What command button code will cause this procedure to run.

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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 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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

747 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

11 Experts available now in Live!

Get 1:1 Help Now