Access MVP (2010-2015)

oOo.oOo.oOo.oOo.oOo.oOo

Changing a Label Caption on a Report

If you do Quotes and Invoicing (or Purchase Orders and Invoicing) they generally share the same layout, the only difference being the Label identifying them.  Rather than creating to reports you can change the Label Caption depending on which Form you are opening it from.

Step 1Caption

Create the Report and for the Label Caption put the name of the one that is used more often.  So, for my Report I put Invoice because I print a lot more invoices than I do quotes.  Make sure the Label is long enough to accommodate the character count of the longest word, i.e. Purchase Order.

Step 2
In the Reports On_Open event place…

 
  If Not IsNull(Me.OpenArgs) Then
      Me.Controls("lblInvoice").Caption = Me.OpenArgs
  End If

…save and close the Report.

Step 3
From the Form that you use to generate your Invoice there is nothing to do, so, go to the one that you use for Quotes.  In Design Mode go to the Command Button(s) you are using for Preview (and Print, if you have one).  Between the Private Sub… and End Sub enter…

    Dim strCaption As String
    strCaption = "Quotation"

Then depending on whether you have a WHERE clause…
No WHERE clause

    DoCmd.OpenReport "rptInvoice", acViewPreview, , , , strCaption

With a WHERE clause (This sample only includes where the WHERE would go.  🙂 )

    DoCmd.OpenReport "rptInvoice", acViewPreview, , strWhere, , strCaption

(Don’t forget some Error Code!)  Save, close and test! All done!

 2,505 total views,  1 views today

Comments are closed.