General Design Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello all,

I have a form that allows users to add records to the database, its
basically a bunch of text boxes that have their control source set to the
fields on my table and a gotorecord,,acnew in my form load. This works ok
however when someone is making an addition they are making the change as soon
as they type the information in and move to the next text box. I have some
poeple that type part way through and then decide they dont want to add this
record and close the form not realizing that they already made changes.

What I want is to have a Save Changes button on the form and it only saves
to the table when they click that. What is the best way to do this? I was
thinking that I could put text boxes on top of the current ones with no
control source and then when they click the button it moves the data to the
corresponding text boxes with the control source. Thank you for any idea's
that you can offer.

James O
 
James, whatever code you are wanting to have in your button's click event,
move it into the BeforeUpdate event of the Form.

Access fires Form_BeforeUpdate for you regardless of how the save was
initiated, and you can do anything you need in the event it triggers for
you.

That's *way* simpler than messing around with duplicating all the controls
as unbound.
 
Not easy ;-)

Something like this ought to get you started:

Dim SaveFlag As Boolean

Sub Form_Current()
SaveFlag = False
End Sub

Sub Form_BeforeInsert(Cancel AS Integer)
If Not SaveFlag Then
Me.Undo
End If
Cancel = Not Me.SaveFlag
End Sub

Sub CmdSave_Click()
SaveFlag = Me.Dirty
Me.Dirty = False
End If

HTH

Pieter
 
Back
Top