Update linked to form

ManuNeko

Registered User.
Local time
Today, 14:33
Joined
Aug 23, 2006
Messages
31
I have a form with personal information, such as name, address and so on. When I update a record, I want to update a field RecUpdate with the current date and time.

I was thinking of doing this in the AfterUpdate event of the form, but I have no idea how to do this.

I know how to write an update statement, but I don't know where and how to link it to the form.
 
I tried something like this:

Code:
Private Sub Form_AfterUpdate()
  db.Execute ("Update Persoon set Persoon.RecUpdate = Now() Where Persoon.ID = " & txtID.Value)
End Sub

But then I get the error: Object required.
 
db doesn't mean anything until you define the object.

Dim db as Database
Set db = CurrentDb
 
Form_AfterUpdate is the wrong event for this. By the time it fires there is no current record. This type of thing normally goes in the Form_BeforeUpdate event:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
  Me.RecUpdate = Now()
End Sub
 

Users who are viewing this thread

Back
Top Bottom