Results 1 to 11 of 11
  1. #1
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Moundridge, Kansas, USA
    Posts
    342
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Print a report and a label at the same time (Acces

    Here is code that I have that prints a checklist for an order when I click the button. I would also like to print a label automatically with the same click. The code in bold is what I added in trying my experiment. It does not work.

    Here's how my labels work. If we ship by FedEx or UPS, I have code that sets my cboLabels to Null as we don't need a label printed for that order. Any order going by Postal Service needs a label. Sometimes I need 2-3 labels, then I enter 2 or 3 in cboLabels. I would like it to print however many labels are indicated in cboLabels. Is this possible in code, or do I have to call a query. I have a query that works like I want it to, but thought maybe I could do it in code.


    Private Sub PrChecklist_Click()
    On Error GoTo Err_PrChecklist_Click
    If IsNull(Me.OrderID) Then
    MsgBox "Create an order before opening the report"
    Exit Sub
    End If

    If Me.Dirty Then
    RunCommand acCmdSaveRecord
    End If

    Dim stDocName As String

    stDocName = "USA Orders Checklist"
    DoCmd.OpenReport stDocName, acViewNormal, , "OrderID=" & Me.OrderID
    stDocName = "zblblNonmemberOrders"
    DoCmd.OpenReport stDocName, acNormal, , "OrderID=" & Me.OrderID & "cboLabels" & Me.cboLabels
    DoCmd.GoToRecord , , acNewRec
    cboCustomerID.SetFocus
    Me.txtDefaultQty = 1

    Exit_PrChecklist_Click:
    Exit Sub

    Err_PrChecklist_Click:
    MsgBox Err.Description
    Resume Exit_PrChecklist_Click

    End Sub

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

    Re: Print a report and a label at the same time (Acces

    DoCmd.OpenReport doesn't let you specify the number of printouts you want. See How to skip used mailing labels and print duplicates in Access 2002 for a method to do so.

  3. #3
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Moundridge, Kansas, USA
    Posts
    342
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Print a report and a label at the same time (A

    OK, that looks like a lot more than I want to get involved in. I'm not throwing it out the window yet though.

    I redid my report so it prints the number of labels through the query. See attachment. It works, my only problem is, when my cboLabels is set to Null, it prints a label with #Error on it. Is there a simple way in code to have it evaluate cboLabels, and if it is null to not run the 'labels' report?

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

    Re: Print a report and a label at the same time (A

    Where does cboLabels come into this? Is it bound to one of the fields in your query?

  5. #5
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Moundridge, Kansas, USA
    Posts
    342
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Print a report and a label at the same time (A

    cboLabels is actually on my order form.

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

    Re: Print a report and a label at the same time (A

    I understand that. But where is the relation with the query you showed in your previous reply?

  7. #7
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Moundridge, Kansas, USA
    Posts
    342
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Print a report and a label at the same time (A

    The query is the source for my labels report, and the Number of Labels tells it how many labels to print.

    I'm not sure if that answers your question or not.

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

    Re: Print a report and a label at the same time (A

    Not really. This isn't working. Could you post a stripped down copy of your database? See <post#=401925>post 401925</post#> for instructions.

  9. #9
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Moundridge, Kansas, USA
    Posts
    342
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Print a report and a label at the same time (A

    Here it is.

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

    Re: Print a report and a label at the same time (A

    Thanks. You can add a condition in the PrChecklist_Click procedure:

    If Not IsNull(Me.cboLabels) Then
    stDocName = "zblblNonmemberOrders"
    DoCmd.OpenReport stDocName, acViewNormal, , "OrderID=" & Me.OrderID
    End If

  11. #11
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Moundridge, Kansas, USA
    Posts
    342
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Print a report and a label at the same time (A

    Thanks heaps. Just what I needed! <img src=/S/yep.gif border=0 alt=yep width=15 height=15>

Posting Permissions

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