Report issues

Jimcb8

Registered User.
Local time
Today, 17:35
Joined
Feb 23, 2012
Messages
98
I created a form called "Client Printout" that is a tab on my home page.
On this form I created a text box to enter the date as mm/dd/yyyy.
I also created a button that when clicked on by the user will print the report. This button, no matter how I try, will only display a small picture of a printer???? (I used a wizard to create the button) How do I have the button say "Print Report" ???

The second question is how do I get the entered date from the form to be printed on my report?

I know this must be simple for experienced developers, but I have been going around in circles trying to get this to work.

Help will be appreciated
 
If you use the Wizard to create the Print Report Button then it should work.
If not you need code in the On Click Event of the button to open the Report.
A better name for your report could be ClientPrintout ie avoid a Space.

Depending on what data is required for your Report you may need to collect some variable results prior to the report being open.
Once this is done, one line of code should open the report with DoCmd.OpenReport

With any control data on your Form. You can access this by using Me. referring to the Form as it should be open, even though you may not see it on your screen.

The code below (in the On Click event) checks for form controls to be populated and messages the operator if theForm is not ready for printing.

The the Report name is built up (we "print" to hdd and want a unique name for archive purposes)

The opens the report with DoCmd.OpenReport and advises the operator (female) if there is further work to do.
Final act is to DoCmd.OutputTo which saves the report.
(Our dates are dd/mm/yyyy)

Code:
Private Sub CmdRptLoansIssuedReport_Click()
On Error GoTo Err_CmdRptLoansIssuedReport_Click
    Dim ReportDate As Date
    Dim ReportName As String
    
    'Lets check if the transaction for this day have been Completed and Balance
    Dim TransferCheck As Currency, GLCheck As Currency
    
    TransferCheck = Me.txtDiffPrincipalAndTransfer
    GLCheck = Me!frmLoansIssuedReportGLDataSubForm.Form!txtGLTotalsCheck
    
    If TransferCheck <> 0 Then
        MsgBox "You must balance the Funds Transfer, Refinance activities before saving this report"
        Exit Sub
    ElseIf GLCheck <> 0 Then
        MsgBox "You must balance the Funds Transfer activities before saving this report"
        Exit Sub
    End If
    
    ReportDate = Me.txtReportDate
    ReportName = CStr(ReportDate)
    ReportName = Right(ReportName, 4)
    ReportName = ReportName & "LIR\LIR "
    ReportName = ReportName & Format(ReportDate, "yyyymmdd")
       
    Dim Response As Integer
    
    Response = MsgBox("Did you complete the Refinance part of Loans Issued Report ?", 68)
    If Response = 6 Then
    'Filter report to display only Date currently showing on FrmLoansIssuedReport
    ' (by ReportDate)
    DoCmd.OpenReport "rptLoansIssuedReport", acViewPreview, , "TRNACTDTE = #" & Format(Me.txtReportDate, "mm\/dd\/yyyy") & "#"
    Else
        MsgBox "Naughty Girl - go back and do it properly"
        Exit Sub
    End If
    
    DoCmd.OutputTo acOutputReport, "rptLoansIssuedReport", acFormatPDF, "V:\Loans Issued Reports\" & ReportName & ".pdf", 0, , , acExportQualityPrint
Exit_CmdRptLoansIssuedReport_Click:
    Exit Sub
Err_CmdRptLoansIssuedReport_Click:
    MsgBox Err.Description
    Resume Exit_CmdRptLoansIssuedReport_Click
    
End Sub

This code is in the Control Source of a text box control on the Report.
Code:
=[Forms]![FrmLoansIssuedReport]![txtReportDate]
When the report is opened, the control is populated by whatever is in the txtReportDate control of the FrmLoansIssuedReport - Form.

Trust the above assists or at least in part:)
 
Thanks for your reply.
Why did the control wizard place a picture of a small printer in the button and does not allow me to add text to the button instead of the picture?
I do not know VB so your code is a bit intimidating to me.
Thanks again for your help
 
You should be able to add and or edit code behind the button.
The Wizard may not have been answered correctly.
Try it again and it may work. Study each question the Wizard asks.

Treat the code as each segment/line to be an action ie step by step and it may make more sense.

The point is that you can use what is on your Form to effect the Report.

Don't be afraid to ask many questions as you resolve an issue and cover new ground.
 
I can't thank you enough for your help and encouragement.
 

Users who are viewing this thread

Back
Top Bottom