Adding a record to a table on form close

jevans

Registered User.
Local time
Today, 03:11
Joined
Oct 11, 2000
Messages
23
What I need to do is update a transaction log table when a form is closed automatically. My table has the following fields: Transaction type and Date. I would like to enter text such as "Email Send" and use the current date as the date data. I need help thanks!!
 
In your OnClose event for the form you can do this:

Private Sub Form_Close()
Dim dbs as Database
Dim tdf as TableDef
Dim rst as RecordSet

Set dbs = CurrentDb ' or whatever DB you are working with
Set tdf = dbs.TableDefs"tblTransactionLog"
Set rst = tdf.openrecordset
with rst.
.addnew
!TransactionType = me.txtTransactionType
!TransactionDate = Now()
.update
end with
rst.close
dbs.close
Set rst = nothing
Set dbs = nothing
End Sub


ntp
 

Users who are viewing this thread

Back
Top Bottom