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