editing data using a form - what's the correct approach?

  • Thread starter Thread starter Morris
  • Start date Start date
M

Morris

Hi everyone,

I'm thinking what should my approach be, to do a simple data edit
correctly. I've got a table with 1500 jobs, User can scroll throufgh
the list, filter, etc, etc, and I want to enable him to edit details
of a particular job. Because the data is quite vulnerable and users
are quite prone to type sth in or change sth without noticing, I
wouldn't want the details to be changed whenever a user changes them
on a form and moves a focus to another control.

IS there any simple way to achieve that that I just don't know about?
Cause if I just make a form.recordsource being this temporary table
called EditedJob - then they can easily change something, scroll the
mouse wheel which takes them to inputting a new record, and alas - the
change has been made without noticing... how can I avoid thinks like
that>?


Thanks in advance
Morris
 
If you to get a confirmation from the user before any change is saved, use
the BeforeUpdate event procedure of the *form* (not control.)

This kind of thing:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If MsgBox("Save?", vbOkCancel, "Confirm") <> vbOk Then
Cancel = True
Me.Undo
End If
End Sub

Alternatively you could set the form's AllowEdits and AllowDeletions
properties to No, and toggle them when the user clicks a button to start the
editing. This avoids accidental edits, but it also affects unbound controls.

So here's what I do:
Locking bound controls on a form and subforms
at:
http://allenbrowne.com/ser-56.html
 
If you to get a confirmation from the user before any change is saved, use
the BeforeUpdate event procedure of the *form* (not control.)

This kind of thing:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If MsgBox("Save?", vbOkCancel, "Confirm") <> vbOk Then
Cancel = True
Me.Undo
End If
End Sub

Alternatively you could set the form's AllowEdits and AllowDeletions
properties to No, and toggle them when the user clicks a button to start the
editing. This avoids accidental edits, but it also affects unbound controls.

Thanks a lot, I like both ways, AS far as I've tested it for it seems
that BeforeUpdate event in conjunction with setting AllowAdditions to
'No' should be enough. AllowAdditions deactivates mouse scroll, and
confirmation forces user's attention if he's unaware of the changes he
made (If he's aware he'll save them with a button)

Thanks a lot!
Morris
 
Back
Top