Results 1 to 6 of 6
  1. #1
    ManuelLavesa is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    113

    Printing Reports from a form


    Hello,
    I have a form with two buttons, one for printing invoices and one for printing Packing Lists. The code I wrote for the Packing List button is as follows:

    Private Sub PrintPackingList_Click()
    Me.StatusID = 1
    DoCmd.RunCommand acCmdSaveRecord
    If DSum("Discount", "OrderDetails", "fkOrderID=" & Me.OrderID) > 0 Then
    DoCmd.OpenReport "EXPackingListReport", acViewPreview, , "fkOrderID=" & Me.OrderID
    DoCmd.PrintOut acPrintAll
    Else
    DoCmd.OpenReport "PackingListReport", acViewPreview, , "fkOrderID=" & Me.OrderID
    DoCmd.PrintOut acPrintAll
    End If
    DoCmd.Close acForm, Me.Name
    End Sub

    The result is that it opens the correct Report, but the cells are empty (no data). This occurs for new and old records. Does anyone know what is wrong with my code. The Invoice button which has similar code is working fine. So I am lost...Thank you for your help

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    why do you have
    DoCmd.PrintOut acPrintAll
    ?

    The DoCmd.OpenReport "EXPackingListReport", acViewPreview is already there. Just click the print button,
    or
    DoCmd.OpenReport "EXPackingListReport"

    and
    your DSUM sums : OrderDetails query/table
    does your report use this same qry? They BOTH should use the same query/tbl.

  3. #3
    ManuelLavesa is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    113
    Thank you for your answer. I got rid of the DoCmd.PrintOut acPrintAll but still the problem remains. Now I found out that if I print first the invoice then the Packing List works. So somehow the data is there in memory right after printing the invoice. These are different report files. So I don't understand what could be going on.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,641
    What do you mean by 'different report files'? If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    ManuelLavesa is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    113
    Attachment 22019 Hello Here is my database, the Problem I am having is that if you go to New Sale Order and make a new entry. Then press the "Print Invoice" button, then the program makes a PDF document saves it in Documents\CustomerInvoices, and names it with the invoice number. Then it will print too, but I suppressed that code with a comment line. The Data shows correctly. Now if you repeat the process, go to New Sales Order enter an order and press the "Print Packing List" button. The Report opens up but there is no data. If you press the button "Edit Sales Order" and enter the invoice number for the last order, and first print the Invoice, Then return and Print the PAcking list. this time the data shows in the printout. So what I would like to accomplish is to print the Packing List first, if possible with the touch of a button. And then Print, and saving the Invoice as a PDF also at the touch of a button. I think I got the program for the Invoice ok, but the one for the Packing list does not work. Thank you for your help with this.

  6. #6
    ManuelLavesa is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    113
    Don't worry about this I found out what was wrong it was in my query... I had a condition there which I forgot and that was why the Packing list could not be printed. Thank you for all your help

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Printing Reports & Send to PDF
    By Dnphm in forum Reports
    Replies: 4
    Last Post: 02-13-2018, 07:25 PM
  2. Help printing off multiple reports.
    By MelonFuel in forum Forms
    Replies: 5
    Last Post: 06-29-2012, 12:25 PM
  3. password before printing reports
    By pnasz in forum Programming
    Replies: 1
    Last Post: 03-12-2012, 05:46 AM
  4. Printing reports off a list box
    By kbandong1 in forum Reports
    Replies: 3
    Last Post: 03-05-2011, 09:51 PM
  5. Printing Reports....
    By Danny Christie in forum Reports
    Replies: 1
    Last Post: 12-06-2006, 05:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums