Hello all,
I am trying to write a code in Access VBA usin SQL syntax. It should work thuis way : when a user changes a specific field in a form, his user name should be added into the table and row, where there was the change. I use event "after update". The codes is here:
There is still some syntax error and I can't see it.
Can you help?
Martina
I am trying to write a code in Access VBA usin SQL syntax. It should work thuis way : when a user changes a specific field in a form, his user name should be added into the table and row, where there was the change. I use event "after update". The codes is here:
Code:
Private Sub comment_AfterUpdate()
SQL "UPDATE dbo_mf_comment SET [user_id] = '" & Environ("username") & "' " _
& " FROM dbo_mf_comment JOIN (SELECT dbo_mf_comment.mf_id, MAX(dbo_mf_comment.[date]) AS MaxDate FROM dbo_mf_comment GROUP BY dbo_mf_comment.mf_id) AS newComment ON dbo_mf_comment.mf_id = '" & Me.mf_id & "' AND newComment.MaxDate = dbo_mf_comment.[date];"
End Sub
Sub SQL(strSQL, Optional dbgprnt)
If Not IsMissing(dbgprnt) Then Debug.Print strSQL
DoCmd.SetWarnings False
If Nz(strSQL, "") <> "" Then DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
End Sub
Can you help?
Martina
Comment