Suggested approaches/best practices

D

Duke Carey

I'm trying to help my wife out with a database for a nonprofit where she is
volunteering. It'll be used by any number of people to enter info about
fundraising efforts, though mostly in single-user mode. I don't want to
spend a ton of time getting it ready for use.

However, I worry about how easy it is to unintentionally delete/edit
existing info on forms. Allen Browne's LockBoundControls helps, but
introduces other concerns:

How do I re-lock the controls when the user moves to a new record?
Form_Current seems to address this, but then how do I trap for a new record
and unlock the controls? Also, does trapping that event cause problems if
the user tries to move to a new form without properly completing the current
edits?

Are there better ways of managing the process of using forms for both
presentation and collection of data and protecting users from themselves?
Any ideas? Anyone? Beuhler?
 
D

Douglas J. Steele

In Form_Current, check the value of the form's NewRecord property:

Private Sub Form_Current()

If Me.NewRecord Then
' New record: don't lock
Else
' Existing record: lock
End If

End Sub
 
A

Allen Browne

Form_Current is the correct event.

To test for a new record, examine the form's NewRecord property:
If Me.NewRecord Then ...

If the user has not completed the existing record satisfactorily (e.g.
required field left blank), the record cannot be saved, so the user can't
move from that record, so Form_Current does not occur for another record
(since they never got there.) Use Form_BeforeUpdate for any record-level
checks that need to run before the record is saved.

The combination of validation in Form_BeforeUpdate, and locking/unlocking in
Form_Current based on Me.NewRecord will be fine.
 
D

Duke Carey

Thank you both for that assistance.

Allen Browne said:
Form_Current is the correct event.

To test for a new record, examine the form's NewRecord property:
If Me.NewRecord Then ...

If the user has not completed the existing record satisfactorily (e.g.
required field left blank), the record cannot be saved, so the user can't
move from that record, so Form_Current does not occur for another record
(since they never got there.) Use Form_BeforeUpdate for any record-level
checks that need to run before the record is saved.

The combination of validation in Form_BeforeUpdate, and locking/unlocking in
Form_Current based on Me.NewRecord will be fine.
 
Top