View Full Version : Append, Update & Print Macro


wishinu
12-21-2005, 10:54 AM
Wow, this is my first post. Bare with me. I have a database that will be used to store receipt information by location. I have a Receipt table, Location table and a Transaction table. The transaction table will store the date & time the User prints out a transaction. I have a preview form that's filtered by locationID and on this form I have a print button that performs append and print process. I need to update the TransmittalID column on the Receipts table with the TransmittalID from the Transmittal table. Can anyone help? Here's my code behind the print transaction button.

Private Sub cmdPrintTrans_Click()
On Error GoTo Err_cmdPrintTrans_Click

DoCmd.SetWarnings False

Dim stDocName As String

stDocName = "rptPaymentTransmittal"

If Me.FilterOn And Len(Me.Filter & "") > 0 Then

DoCmd.RunSQL "INSERT INTO tblTransmittal (TransmittalDate, TransmittalTime) VALUES (Date(), Time());"

DoCmd.OpenReport stDocName, acViewPreview, WhereCondition:=Me.Filter
Else
DoCmd.OpenReport stDocName, acViewPreview
End If

DoCmd.SetWarnings True

Exit_cmdPrintTrans_Click:
Exit Sub

Err_cmdPrintTrans_Click:
MsgBox Err.Description
Resume Exit_cmdPrintTrans_Click
End Sub