How can I setup Access 2003 to prompt me before it saves a record

T

tcdoriot

How can I setup Access 2003 to prompt me before it saves a record in form
view or any other view

Your help is much appreciated

Tim
 
R

Rick Brandt

tcdoriot said:
How can I setup Access 2003 to prompt me before it saves a record in form
view or any other view

Your help is much appreciated

First off I would question why on earth you would want to do such a thing. If
you don't want to add or change a record then keep your fingers off the keys.

In a Form you could add code to the BeforeUpdate event...

If MsgBox("Save Changes?",vbYesNo) = vbNo Then
Cancel = True
Me.Undo
End If

Outside a form you cannot do what you are asking.
 
T

tcdoriot

Rick Brandt said:
First off I would question why on earth you would want to do such a thing. If
you don't want to add or change a record then keep your fingers off the keys.

In a Form you could add code to the BeforeUpdate event...

If MsgBox("Save Changes?",vbYesNo) = vbNo Then
Cancel = True
Me.Undo
End If

Outside a form you cannot do what you are asking.

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


Hello Rick
Thank you for the reply..yes it sounds stupid..but I built the database for
a company and they want an extra step before one of the no brains idiots in
the shop saves a record..

I am very limited on my experience with databases..I basically did the
tutorial and created it.

Can you tell me where to put that code.

Thank you and sorry for my lack of knowledge and experience with this.

Tim
 
R

Rick Brandt

tcdoriot said:
Thank you for the reply..yes it sounds stupid..but I built the database for
a company and they want an extra step before one of the no brains idiots in
the shop saves a record..

I am very limited on my experience with databases..I basically did the
tutorial and created it.

Can you tell me where to put that code.

As stated in my first response, you would put it in the BeforeUpdate event of
the form. That event fires just before any changes are saved and it provides
the Cancel argument to stop the changes from being committed.

In form design view bring up the property sheet, look at the "Events" tab, and
then find the one named "Before Update". From the drop-list choose "[Event
Procedure]", then click the build button [...] immediately to the right.

This will take you to the VBA code editor window pre-positioned where the code
lines need to be entered.
 
S

Steve Huff

In a form you would put the code in the "Before Update" and "Before Insert"
to pop up a message box or whatever it is you are wanting to tell the user.
If you want to cancel the insert or update just set the Cancel variable
equal to True in those events.

-Steve Huff
 
R

Rick Brandt

Steve Huff said:
In a form you would put the code in the "Before Update" and "Before Insert" to
pop up a message box or whatever it is you are wanting to tell the user. If
you want to cancel the insert or update just set the Cancel variable equal to
True in those events.

You wouldn't want this in BeforeInsert That fires at the first keystroke of a
new record, not when it is about to be saved.
 
T

tcdoriot

Thanks Rick for all the help.

Tim


Rick Brandt said:
You wouldn't want this in BeforeInsert That fires at the first keystroke of a
new record, not when it is about to be saved.
 
T

tcdoriot

Hey Rick, I ran into a little problem I was hoping you could help me with

after I added the even to "before UPdate" I went to test .. when the data is
changed and I tell it to save it does everything correctly...but when I tell
it not to save I get an error message


You can't save this record at this time.

"Microsoft Office Access may have encountered an error while trying to save
a record. If you close this object now, the data changes you made will be
lost. Do you want to close the database object anyway?



Any ideas why this is happening?

I copied the data to my home pc and everything worked ok..now the database
and the event is on the work pc which is on a network and I get this error
message.

Did I imput the event wrong

Here is a copy of what I got in there

Private Sub Form_BeforeUpdate(Cancel As Integer)

If MsgBox("Save Changes?", vbYesNo) = vbNo Then
Cancel = True
Me.Undo
End If

End Sub


Thank you very much for your help

Tim
 
Top