A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Close form without Updating



 
 
Thread Tools Display Modes
  #1  
Old August 30th, 2006, 12:17 PM posted to microsoft.public.access.forms
swifty
external usenet poster
 
Posts: 10
Default Close form without Updating

I'm trying to create forms for adding data to tables, trouble is when you
close the form, if there is anything in the text boxes it tries to update the
table. I don't want closing the form to run an update, it would be useful if
it asked first maybe, but not without confirmation but can't see how to stop
it. I have tried adding a button to update, and another to close, but even my
own close button is trying to update the table. I have also tried using code
(below) as posted by someone else prior to an update to confirm whether or
not data should be saved, but the form still then goes on to try to save even
if you say no.

If MsgBox("Do you want to save the changes?", vbYesNo,"Confirm Change")
= vbNo Then
Cancel = True
Me.Undo
End If

  #2  
Old August 30th, 2006, 02:00 PM posted to microsoft.public.access.forms
Svetlana
external usenet poster
 
Posts: 80
Default Close form without Updating

Instead of Me.Undo try DoCmd.RunCommand acCmdUndo

  #3  
Old August 30th, 2006, 02:11 PM posted to microsoft.public.access.forms
swifty
external usenet poster
 
Posts: 10
Default Close form without Updating

Thanks, unfortunately it is still trying to update. I'm only using the red
cross at the top of the form and I just want it to discard everything and
close, this only works if there are no entries on the form, as soon as there
is anything on the form it tries to use it to update the table. Any other
ideas?! )

"Svetlana" wrote:

Instead of Me.Undo try DoCmd.RunCommand acCmdUndo


  #4  
Old August 30th, 2006, 02:16 PM posted to microsoft.public.access.forms
Klatuu
external usenet poster
 
Posts: 7,074
Default Close form without Updating

It is not your close button trying to do the update, it is the Close event of
the form.
Svetlana's suggestion will do the same thing. You need to move the code to
the Unload event of the form.

"Swifty" wrote:

I'm trying to create forms for adding data to tables, trouble is when you
close the form, if there is anything in the text boxes it tries to update the
table. I don't want closing the form to run an update, it would be useful if
it asked first maybe, but not without confirmation but can't see how to stop
it. I have tried adding a button to update, and another to close, but even my
own close button is trying to update the table. I have also tried using code
(below) as posted by someone else prior to an update to confirm whether or
not data should be saved, but the form still then goes on to try to save even
if you say no.

If MsgBox("Do you want to save the changes?", vbYesNo,"Confirm Change")
= vbNo Then
Cancel = True
Me.Undo
End If

  #5  
Old August 30th, 2006, 02:26 PM posted to microsoft.public.access.forms
swifty
external usenet poster
 
Posts: 10
Default Close form without Updating

Hmmmmm, it's now producing more errors than before. It says the Undo command
isn't available. I've put the code under the unload event. In fact, I can't
even close the form when there's no data entered at all now.

"Klatuu" wrote:

It is not your close button trying to do the update, it is the Close event of
the form.
Svetlana's suggestion will do the same thing. You need to move the code to
the Unload event of the form.

"Swifty" wrote:

I'm trying to create forms for adding data to tables, trouble is when you
close the form, if there is anything in the text boxes it tries to update the
table. I don't want closing the form to run an update, it would be useful if
it asked first maybe, but not without confirmation but can't see how to stop
it. I have tried adding a button to update, and another to close, but even my
own close button is trying to update the table. I have also tried using code
(below) as posted by someone else prior to an update to confirm whether or
not data should be saved, but the form still then goes on to try to save even
if you say no.

If MsgBox("Do you want to save the changes?", vbYesNo,"Confirm Change")
= vbNo Then
Cancel = True
Me.Undo
End If

  #6  
Old August 30th, 2006, 02:31 PM posted to microsoft.public.access.forms
Klatuu
external usenet poster
 
Posts: 7,074
Default Close form without Updating

I forgot to mention, you first need to check to see if it needs updating:

If Me.Dirty Then
If MsgBox("Do you want to save the changes?", vbYesNo,"Confirm Change") _
= vbNo Then
Cancel = True
Me.Undo
End If


"Swifty" wrote:

Hmmmmm, it's now producing more errors than before. It says the Undo command
isn't available. I've put the code under the unload event. In fact, I can't
even close the form when there's no data entered at all now.

"Klatuu" wrote:

It is not your close button trying to do the update, it is the Close event of
the form.
Svetlana's suggestion will do the same thing. You need to move the code to
the Unload event of the form.

"Swifty" wrote:

I'm trying to create forms for adding data to tables, trouble is when you
close the form, if there is anything in the text boxes it tries to update the
table. I don't want closing the form to run an update, it would be useful if
it asked first maybe, but not without confirmation but can't see how to stop
it. I have tried adding a button to update, and another to close, but even my
own close button is trying to update the table. I have also tried using code
(below) as posted by someone else prior to an update to confirm whether or
not data should be saved, but the form still then goes on to try to save even
if you say no.

If MsgBox("Do you want to save the changes?", vbYesNo,"Confirm Change")
= vbNo Then
Cancel = True
Me.Undo
End If

  #7  
Old August 30th, 2006, 02:38 PM posted to microsoft.public.access.forms
swifty
external usenet poster
 
Posts: 10
Default Close form without Updating

Hi again... Ok, I've put that in the unload, (and added another End If!), it
now closes if there's nothing in the form again, but if there is any text,
still tries to validate what's in the boxes against what should be in the
table, complains if it fails the validation tests and says it cannot be saved
do you still want to close, or updates it if validation succeeds. If someone
starts making an entry and then wants to close the form and abandon what they
were doing that doesn't seem unreasonable to me?

"Klatuu" wrote:

I forgot to mention, you first need to check to see if it needs updating:

If Me.Dirty Then
If MsgBox("Do you want to save the changes?", vbYesNo,"Confirm Change") _
= vbNo Then
Cancel = True
Me.Undo
End If


"Swifty" wrote:

Hmmmmm, it's now producing more errors than before. It says the Undo command
isn't available. I've put the code under the unload event. In fact, I can't
even close the form when there's no data entered at all now.

"Klatuu" wrote:

It is not your close button trying to do the update, it is the Close event of
the form.
Svetlana's suggestion will do the same thing. You need to move the code to
the Unload event of the form.

"Swifty" wrote:

I'm trying to create forms for adding data to tables, trouble is when you
close the form, if there is anything in the text boxes it tries to update the
table. I don't want closing the form to run an update, it would be useful if
it asked first maybe, but not without confirmation but can't see how to stop
it. I have tried adding a button to update, and another to close, but even my
own close button is trying to update the table. I have also tried using code
(below) as posted by someone else prior to an update to confirm whether or
not data should be saved, but the form still then goes on to try to save even
if you say no.

If MsgBox("Do you want to save the changes?", vbYesNo,"Confirm Change")
= vbNo Then
Cancel = True
Me.Undo
End If

  #8  
Old August 30th, 2006, 03:01 PM posted to microsoft.public.access.forms
Klatuu
external usenet poster
 
Posts: 7,074
Default Close form without Updating

I missed that End If, thanks.

Where is the other validation occuring? How are you handling it?
That could easily be the problem.

"Swifty" wrote:

Hi again... Ok, I've put that in the unload, (and added another End If!), it
now closes if there's nothing in the form again, but if there is any text,
still tries to validate what's in the boxes against what should be in the
table, complains if it fails the validation tests and says it cannot be saved
do you still want to close, or updates it if validation succeeds. If someone
starts making an entry and then wants to close the form and abandon what they
were doing that doesn't seem unreasonable to me?

"Klatuu" wrote:

I forgot to mention, you first need to check to see if it needs updating:

If Me.Dirty Then
If MsgBox("Do you want to save the changes?", vbYesNo,"Confirm Change") _
= vbNo Then
Cancel = True
Me.Undo
End If


"Swifty" wrote:

Hmmmmm, it's now producing more errors than before. It says the Undo command
isn't available. I've put the code under the unload event. In fact, I can't
even close the form when there's no data entered at all now.

"Klatuu" wrote:

It is not your close button trying to do the update, it is the Close event of
the form.
Svetlana's suggestion will do the same thing. You need to move the code to
the Unload event of the form.

"Swifty" wrote:

I'm trying to create forms for adding data to tables, trouble is when you
close the form, if there is anything in the text boxes it tries to update the
table. I don't want closing the form to run an update, it would be useful if
it asked first maybe, but not without confirmation but can't see how to stop
it. I have tried adding a button to update, and another to close, but even my
own close button is trying to update the table. I have also tried using code
(below) as posted by someone else prior to an update to confirm whether or
not data should be saved, but the form still then goes on to try to save even
if you say no.

If MsgBox("Do you want to save the changes?", vbYesNo,"Confirm Change")
= vbNo Then
Cancel = True
Me.Undo
End If

  #9  
Old August 30th, 2006, 03:30 PM posted to microsoft.public.access.forms
swifty
external usenet poster
 
Posts: 10
Default Close form without Updating

The validation is on the table, if you try to enter a value which is not in
the correct format it won't allow the entry. The point is, it shouldn't even
be doing anything if you just want to close the form, if the data does look
valid it saves it, I want it to just throw any values away, not start
checking if they pass validation on the table field.

"Klatuu" wrote:

I missed that End If, thanks.

Where is the other validation occuring? How are you handling it?
That could easily be the problem.

"Swifty" wrote:

Hi again... Ok, I've put that in the unload, (and added another End If!), it
now closes if there's nothing in the form again, but if there is any text,
still tries to validate what's in the boxes against what should be in the
table, complains if it fails the validation tests and says it cannot be saved
do you still want to close, or updates it if validation succeeds. If someone
starts making an entry and then wants to close the form and abandon what they
were doing that doesn't seem unreasonable to me?

"Klatuu" wrote:

I forgot to mention, you first need to check to see if it needs updating:

If Me.Dirty Then
If MsgBox("Do you want to save the changes?", vbYesNo,"Confirm Change") _
= vbNo Then
Cancel = True
Me.Undo
End If


"Swifty" wrote:

Hmmmmm, it's now producing more errors than before. It says the Undo command
isn't available. I've put the code under the unload event. In fact, I can't
even close the form when there's no data entered at all now.

"Klatuu" wrote:

It is not your close button trying to do the update, it is the Close event of
the form.
Svetlana's suggestion will do the same thing. You need to move the code to
the Unload event of the form.

"Swifty" wrote:

I'm trying to create forms for adding data to tables, trouble is when you
close the form, if there is anything in the text boxes it tries to update the
table. I don't want closing the form to run an update, it would be useful if
it asked first maybe, but not without confirmation but can't see how to stop
it. I have tried adding a button to update, and another to close, but even my
own close button is trying to update the table. I have also tried using code
(below) as posted by someone else prior to an update to confirm whether or
not data should be saved, but the form still then goes on to try to save even
if you say no.

If MsgBox("Do you want to save the changes?", vbYesNo,"Confirm Change")
= vbNo Then
Cancel = True
Me.Undo
End If

  #10  
Old August 30th, 2006, 03:43 PM posted to microsoft.public.access.forms
Klatuu
external usenet poster
 
Posts: 7,074
Default Close form without Updating

This is exactly why I never use field or table level validation. You have
very little control over it. I do all my validation in the form, either at
the control or the form level. That way, I have control over whether it does
it, how it does it, and when it does it. The only advantage to table/field
validation, is that it is always consistent throughout the application.

"Swifty" wrote:

The validation is on the table, if you try to enter a value which is not in
the correct format it won't allow the entry. The point is, it shouldn't even
be doing anything if you just want to close the form, if the data does look
valid it saves it, I want it to just throw any values away, not start
checking if they pass validation on the table field.

"Klatuu" wrote:

I missed that End If, thanks.

Where is the other validation occuring? How are you handling it?
That could easily be the problem.

"Swifty" wrote:

Hi again... Ok, I've put that in the unload, (and added another End If!), it
now closes if there's nothing in the form again, but if there is any text,
still tries to validate what's in the boxes against what should be in the
table, complains if it fails the validation tests and says it cannot be saved
do you still want to close, or updates it if validation succeeds. If someone
starts making an entry and then wants to close the form and abandon what they
were doing that doesn't seem unreasonable to me?

"Klatuu" wrote:

I forgot to mention, you first need to check to see if it needs updating:

If Me.Dirty Then
If MsgBox("Do you want to save the changes?", vbYesNo,"Confirm Change") _
= vbNo Then
Cancel = True
Me.Undo
End If


"Swifty" wrote:

Hmmmmm, it's now producing more errors than before. It says the Undo command
isn't available. I've put the code under the unload event. In fact, I can't
even close the form when there's no data entered at all now.

"Klatuu" wrote:

It is not your close button trying to do the update, it is the Close event of
the form.
Svetlana's suggestion will do the same thing. You need to move the code to
the Unload event of the form.

"Swifty" wrote:

I'm trying to create forms for adding data to tables, trouble is when you
close the form, if there is anything in the text boxes it tries to update the
table. I don't want closing the form to run an update, it would be useful if
it asked first maybe, but not without confirmation but can't see how to stop
it. I have tried adding a button to update, and another to close, but even my
own close button is trying to update the table. I have also tried using code
(below) as posted by someone else prior to an update to confirm whether or
not data should be saved, but the form still then goes on to try to save even
if you say no.

If MsgBox("Do you want to save the changes?", vbYesNo,"Confirm Change")
= vbNo Then
Cancel = True
Me.Undo
End If

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:54 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.