AddNew when a report is printed

Lisad

Access Beginner
Local time
Today, 08:24
Joined
Jan 26, 2005
Messages
31
I am trying to add a record to TBLLetterHistory when RPTGeneralLetter is printed, to record the history of the report. The report is based upon a Query. QRYGeneralLetter is based upon a combo box selection on FRMLetter(CustomerID - select which customer to run the report for).

I am able to add a record in the table which records the date and the report name, however I am unable to record the CustomerID so I know when the report has been printed for a particular customer.

I thought I would need something like this:-
rst!CustomerID = Forms!FRMLetter!ComboCoName

...but apparently not! Here is my code so far...


Private Sub Report_Activate()
Flag = 0
End Sub

Private Sub Report_Deactivate()
Flat = -1
End Sub

Sub ReportHeader_Print(Cancel As Integer, PrintCount As Integer)

Dim dbs As DAO.Database, rst As DAO.Recordset
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("TBLLetterHistory")

Flag = Flag + 1
' If the current value of Flag = 1, then a hard copy of the
' report is printing, so add a new record to the history table.
If Flag = 1 Then
rst.AddNew
rst!ReportName = "RPTGeneralLetter"
rst!Date = Now
rst.Update
Flag = 0

End If

End Sub
Any help is much appreciated! I am fairly new to all this VB!
 

Users who are viewing this thread

Back
Top Bottom