When I run the code below on one of my computers, it works fine. In fact I have tested it on several other computers, all running either Windows 7 Pro and Windows 7 Home Premium. Some of the computers running 7 Pro are 32 bit, some 64 bit. The 7 Home is 64bit. Unfortunately on the computer (running Home Premium 64 bit) where I do most of my development work the code brings up “Run Time Error 5, Invalid procedure call or argument”.
The code is for a memo field called “Notes” that is the adding date and username stamp. Before I added the On Error Resume Next, it would always bring up the error message when I tried to edit the memo field. After inserting the On Error Resume Next, it worked, but not on the one computer. Is this just at a gremlin on this particular computer? Or is there some better code to use than the On Error Resume Next? I am developing the DB for work use and at least six people will be using it; don’t want one or more to have the same problem.
My code:
Private Sub Notes_AfterUpdate()
On Error Resume Next
If Notes = "" Or IsNull(Me.Notes.OldValue) Then
Me.Notes = Date & " " & Me.Notes & " " & User1
Else
Me.Notes = Left(Me.Notes, Len(Me.Notes.OldValue)) & _
" " & Date & " " & Right(Me.Notes, Len(Me.Notes) - Len(Me.Notes.OldValue)) & " " & User1
Me.Dirty = False
End If
End Sub