How to stop entry into DB

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

Guest

I have some text boxes for data entry. I have five text boxes if I fill in
one or two text boxes and then exit the program it will save the information
in the DB that has been entered. I need it to disregard any information
typed in if the application is closed.

Thanks
 
What I ment to say: If a person enters some data then decides to exit out of
the program then to disrgard what they had typed in.
 
I don't think there is a way to do that without prompting the user. You
could ask the user (every time they close the form while it is dirty) if the
data should be saved. There have been other posts out there (many of them)
that better explain how to prompt the user to save changes.

Look back at those for more details.

Rick B
 
I have some text boxes for data entry. I have five text boxes if I fill in
one or two text boxes and then exit the program it will save the information
in the DB that has been entered. I need it to disregard any information
typed in if the application is closed.

Thanks

This is what you need. To make this happen you then have to do as is
suggested for the BeforeUpdate event by testing that all the controls
have been filled in and if not then invoking the form.Undo method.

UNDO METHOD
--------------
You can use the Undo method to reset a control or form when its value
has been changed. For example, you can use the Undo method to clear a
change to a record that contains an invalid entry.

Syntax

object.Undo

The Undo method has the following argument.

Argument Description
object A Form object or a Control object.

Remarks
If the Undo method is applied to a form, all changes to the current
record are lost. If the Undo method is applied to a control, only the
control itself is affected.

This method must be applied before the form or control is updated. You
may want to include this method in a form's BeforeUpdate event or in a
control's Change event.

The Undo method offers an alternative to using the SendKeys statement
to send the value of the ESC key in an event procedure.

Brett
Cheers,
Brett
 
So here is my exit button statement:
Private Sub pat_ent_Exit_Click()
On Error GoTo Err_pat_ent_Exit_Click

DoCmd.Close

Exit_pat_ent_Exit_Click:
Exit Sub

Err_pat_ent_Exit_Click:
MsgBox Err.description
Resume Exit_pat_ent_Exit_Click

End Sub

How do I put in the beforeUpdate?
Is it just beforeUpdate.FirstName.Undo
to undo the firstName field.

Also to apply it to the whole form is it the same thing
beforeUpdate.Patient_Registry.Undo
 
How do I put in the beforeUpdate?
Is it just beforeUpdate.FirstName.Undo
to undo the firstName field.

It depends. You can do it for the whole form or just one field. You
original question was to know how to do this if only 3 of the 5 fields
were filled in. In that case, it has to be on the Form Property.

No, when you open the form in Design View, open the Properties Window,
go to the Events Tab and make the BeforeUpdate property an Event
Procedure.

Then paste the code in and modify it - replace "frmMyForm" with the
name of your form.

You will also then have to add some If Then Else clause to test to see
that all the 5 fields have been filled in, but the code I provided is
the wrapper for all of that.

Brett


So here is my exit button statement:
Private Sub pat_ent_Exit_Click()
On Error GoTo Err_pat_ent_Exit_Click

DoCmd.Close

Exit_pat_ent_Exit_Click:
Exit Sub

Err_pat_ent_Exit_Click:
MsgBox Err.description
Resume Exit_pat_ent_Exit_Click

End Sub

How do I put in the beforeUpdate?
Is it just beforeUpdate.FirstName.Undo
to undo the firstName field.

Also to apply it to the whole form is it the same thing
beforeUpdate.Patient_Registry.Undo

Cheers,
Brett
 
Back
Top