sgtschultz said:
I have a form to enter data for service calls. Is there a way to
automatically lock the data when I start a new record so the information I
entered on the previous record can't be altered/deleted? Thanks in advance
for the help
-Josh-
Yes, but you're probably going to need a way to unlock them on those
occasions when you really do need to edit a previous call record.
To set things so that existing records can't be edited, use code in the
form's Current event like this:
'----- start of example code -----
Private Sub Form_Current()
If Me.NewRecord Then
Me.AllowEdits = True
Me.AllowDeletions = True
Else
Me.AllowEdits = False
Me.AllowDeletions = False
End If
End Sub
'----- end of example code -----
You might have a command button to unlock the a record:
'----- start of code for button -----
Private Sub cmdUnlock_Click()
Me.AllowEdits = True
Me.AllowDeletions = True
End Sub
'----- end of code for button -----
Note that setting the form's AllowEdits property to False will prevent you
from modifying *unbound* controls on the form as well, so you can't use (for
example) combo boxes for navigation. If that's a problem on this form,
there are ways around it that involve more complicated code than I posted
above.