Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem updating a field [Record Edited] when using a main and subform

Status
Not open for further replies.

Hyde

Technical User
Sep 8, 2000
12
US
I was able to accomplish this task using the Before_update event on both the main and subform. This worked for a day or two, but then I need to make a small change. The change did not work, so I put the code back to the original code which worked and now the [Record Edited] field updates when you tab from the main form to the subform, and from the subform to the main form. Below is the code I am currently using in the main form:

Private Sub Form_BeforeUpdate(Cancel As Integer)

Dim db As DAO.Database
Dim rec As DAO.Recordset
Dim wks As DAO.Workspace

Set db = CurrentDb()
Set rec = db.OpenRecordset("tblRolodex")
Set wks = DBEngine(0)

[Sys_User_ID_Edited].Locked = False
[Sys_User_ID_Edited] = wks.UserName

[Record_Edited].Locked = False
[Record_Edited] = Now()

'rec.MoveNext rec.Close
Set rec = Nothing

End Sub

The subform's method:

Private Sub Form_BeforeUpdate(Cancel As Integer)

Dim db As DAO.Database
Dim rec As DAO.Recordset
Dim wks As DAO.Workspace

Set db = CurrentDb()
Set rec = db.OpenRecordset ("tblRolodexContact")
Set wks = DBEngine(0)

Forms!frmRolodex.[Sys_User_ID_Edited].Locked = False
Forms!frmRolodex.[Sys_User_ID_Edited] = wks.UserName

Forms!frmRolodex.[Record_Edited].Locked = False
Forms!frmRolodex.[Record_Edited] = Now()

rec.MoveNext
rec.Close
Set rec = Nothing

End Sub

Thanks,

Suzanne
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top