Locking a form

S

sgtschultz

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-
 
B

Brian

You can set the DataEntry property to True. This will never display old
records when opening the form and will allow users to enter data but not
change old records. If it is a Continuous form, records in the current
session will continue to be displayed but cannot be changed after entry.
Every time the form is opened, it will show no prior records.

If you also want to provide some way to edit the data or view old records,
you will need to make a different form or have some settings that allow
certain users to open it with DataEntry=False.
 
B

Brian

I misspoke in my first e-mail a little. In a continuous form, prior records
can still be edited within the current session (not an issue if you are using
Single Form). You may need to also set AllowEdits = False in the form
properties to disallow editing of prior records in the same session.
 
D

Dirk Goldgar

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top