Results 1 to 7 of 7
  1. #1
    4 Star Lounger
    Join Date
    Sep 2002
    Location
    Stafford, Staffordshire, England
    Posts
    585
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Print a report based on one of two options (A2002)

    Using the toolbox wizard, I have placed a button on a form which prints a report. The report is based on a query which uses the Invoice Number on the form as the criterion for record selection. This works perfectly.
    Also on the form is a textbox (Payment Type) from which a choice of "Self-funded" or "Insurance" can be made. The user would like to print off one of two different reports based on which Payment type is selected. The two different reports use different queries to populate them. How can I modify the code behind the button to accomplish this? Or is there a better way?
    TIA
    <font color=blue><font face="Script MT Bold"><big>Rob</big></font face=script></font color=blue>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Print a report based on one of two options (A2002)

    Hi Rob,

    If the only possible choices are Self-funded and Insurance, I wouldn't use a text box for Payment Type, but a combo box or an option group with two option buttons.

    With the current setup, you could use code similar to the following:

    Private Sub cmdReport_Click()
    Dim stDocName As String

    If Me.[txtPaymentType] = "Self-funded" Then
    stDocName = "rptSelfFunded"
    Else
    stDocName = "rptInsurance"
    End If

    DoCmd.OpenReport stDocName, acViewPreview
    End Sub

    You must substitute the correct names for the command button, text box, and reports.

  3. #3
    4 Star Lounger
    Join Date
    Sep 2002
    Location
    Stafford, Staffordshire, England
    Posts
    585
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print a report based on one of two options (A2

    Thanks, Hans, It's just what I needed. I made a mistake. I was using a combobox. The line before the "End Sub" opens the form in preview mode. What is the equivalent code to print without preview?
    <font color=blue><font face="Script MT Bold"><big>Rob</big></font face=script></font color=blue>

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Print a report based on one of two options (A2

    Change acViewPreview to acViewNormal. This will send the report directly to the printer (printing is the "normal" action for a report).

    PS Love your new signature! <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15>

  5. #5
    4 Star Lounger
    Join Date
    Sep 2002
    Location
    Stafford, Staffordshire, England
    Posts
    585
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print a report based on one of two options (A2

    Thanks. I knew you'd spot it. Would it be more accurate to say "The Netherlands lie......." or "The Netherlands lies...." etc?
    <font color=blue><font face="Script MT Bold"><big>Rob</big></font face=script></font color=blue>

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Print a report based on one of two options (A2

    The official name of my country is The Netherlands, plural, so based on that it should be "The Netherlands lie ...". But I won't be offended if you keep the shorter "Holland lies ...".

  7. #7
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print a report based on one of two options (A2

    OTOH, since (broadly speaking) Holland is a sandbank & the rest of the country is not - was Holland itself (other than perhaps the fringes) ever "saved from being dammed" (by the likes of Hans Brinker & various others)? <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>
    Gre

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •