Lock records after data entry

P

Pat Dools

Hi,

I want to 'lock' records after they are entered into a form-- either in code
on close of the form or behind a Command Button. We currently have forms in
a series that you get to by hitting a 'Next' Command Button. This button has
code to go back to the 'initial' form (which is opened at database startup
and remains open as the data entry person progresses thru the series), gather
four header fields, and place those values in the four header fields in the
form you advance to. This ensures
that you are entering data for the same patient in the series (see code
below):

Private Sub Form_Current()
Call SetAutoValues(Me)
End Sub

Private Sub Next_Click()
On Error GoTo Err_Next_Click
Call OpenNextForm(Me.Name)
Exit_Next_Click:
Exit Sub
Err_Next_Click:
DoCmd.Close acForm, Me.Name
Resume Exit_Next_Click
End Sub

Sub SetAutoValues(frm As Form)
On Error GoTo SetAutoValues_err
' Set Automatic Values in each form in series
With frm
!studyday = Forms!fScrEligCriteria!studyday
!id = Forms!fScrEligCriteria!id
!ptin = Forms!fScrEligCriteria!ptin
!site = Forms!fScrEligCriteria!site
End With
SetAutoValues_err:
Resume Next
End Sub

Everything works great, BUT we have discovered a potential problem. Since
the 'SetAutoValues' is in the 'On Current:' property of all the forms in the
series (except for the initial 'fScrEligCriteria' form), if you have the
'initial' form open ('fScrEligCriteria'), and then you go back to the main
database window, and open another form (any form) and advance thru
already-existing records using the Record Navigator arrows at the bottom of
the form, the four header fields will all get over-written with the values
that match the values in the four header fields present in the open initial
form (which is set to open on database open so this code will work in the
first place). While this falls out of the normal workflow we have set up for
our data entry people, and SHOULDN'T happen, can we 'lock' records that have
been entered already, so that if they do navigate thru records using the Form
Record Navigators that these header fields cannot get overwritten by
activating the 'SetAutoValues' code? We're just trying to protect
already-existing records from user error, so I'm open to suggestions.

Thanks.
 
B

Bill Gates

Hi, Sorry if this is not what you were after but you can lock the field once
you have chosen a record by creating an after update event on the text box or
combo box, etc.

For example:

text1.locked = true

You can create a button to unlock if you wanted with the same code but
=false if they want to select a different record.
 

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