newbie46
asked on
How does Access 2007 know ID of record being deleted from form?
I am inserting records into a Change History table when a record is deleted from a form (using the Delete button on the keyboard). Yet, when deleting the record, Access doesn't seem to know what record is being deleted.
How do I access information about the record being deleted? I have the following code in VB:
Private Sub Form_BeforeDelConfirm (Cancel As Integer, Response As Integer)
Dim db As DAO.Database
Set db = CurrentDb()
db.Execute "INSERT INTO ChangeHistory (RecordID, DateDeleted) VALUES ( '" & _
me.RecordID & "', Now())"
How can I access the RecordId of the record being deleted?
How do I access information about the record being deleted? I have the following code in VB:
Private Sub Form_BeforeDelConfirm (Cancel As Integer, Response As Integer)
Dim db As DAO.Database
Set db = CurrentDb()
db.Execute "INSERT INTO ChangeHistory (RecordID, DateDeleted) VALUES ( '" & _
me.RecordID & "', Now())"
How can I access the RecordId of the record being deleted?
If you click on the record selector (or some other method of selecting the record) first then pres the delete key it will definitely delete the record.
i agree - i didn't read the question as saying that.
If that's what the poster is doing then I don't see why the id would not be available.
If that's what the poster is doing then I don't see why the id would not be available.
ASKER
TheHiTechCoach,
When I click on the record selector and then click delete on the keyboard, the record is deleted. Before the record is deleted, I need to track its record id and store this in a Change History table. How do I access the record's id prior to it being deleted?
When I click on the record selector and then click delete on the keyboard, the record is deleted. Before the record is deleted, I need to track its record id and store this in a Change History table. How do I access the record's id prior to it being deleted?
ASKER
When I step through BeforeDelConfirm code in VBA, the record id is null. Is there a way to access this id. I tried using me.recordset.absoluteposit ion and me.recordset.recordcount to try to access this id, but to no avail.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you. Using OnDelete did the trick.
You need to add your own Delete record button, or use the Delete on the ribbon.