What is "LastAccessed"? Are you only trying to track updates to one field?
Usually the Last update would refer to ANY record change, not just a change
to a single field. That's why I suggested the form's BeforeUpdate event
rather than the BeforeUpdate event of each control.
Now for some professional advice. When you add controls to a form/report
manually, go in to the properties and change the Name property before you
add any code. In two months are you going to know what Command31 is? If
you change the name now, Access will loose its association with the existing
code so you'll need to move it from where it is to the click event with the
new name. Then delete the code for Command31. Secondly, and this is
Microsoft's fault not yours, the wizards usually generate DoMenuItem
commands that are based on the menu structure of Access95! Do you know what
the 10th item in the Edit Menu of Access 95 is? I don't either. so I have
no idea what the click event is actually going to do. So now, while the
purpose of this code is still clear to you, change it to use the appropriate
DoCmd.RunCommand method. Intellisense will give you a list of available
values. You just need to scroll to the one you want. Keep in mind that for
record operations, the command will end with "Record". For example
DoCmd.RunCommand acCmdSave will save the form NOT the record.
DoCmd.RunCommand acCmdSaveRecord will save the current record.
I must just be doing SOMETHING wrong.. Here's what I have done, and it
just is not working...
Name.... LastAccessed
Control Source.... Last Accessed
Enabled.... Yes
Locked.... Yes
Before Update....[Event Procedure]
After Update.... Nothing
On (All On items Are the same answer).... Nothing
As for the [Event Procedure] Code...
Private Sub Command31_Click()
On Error GoTo Err_Command31_Click
Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70
Exit_Command31_Click:
Exit Sub
Err_Command31_Click:
MsgBox Err.Description
Resume Exit_Command31_Click
End Sub
Private Sub LastAccessed_BeforeUpdate(Cancel As Integer)
Me.UpdatedDate = Now()
End Sub
As for the answer of how I need it to update... I need the field to
update ONLY when someone makes a change to one of the fields in the
form. That way, when I build a Query against the date, I can see when
the last change was.
Thanx so far!- Hide quoted text -
- Show quoted text -