Solved

What command button code will cause this procedure to run.

Posted on 2000-03-02
3
137 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 Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

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 …
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…
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…
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
Course of the Month7 days, 13 hours left to enroll

632 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