469,631 Members | 1,281 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,631 developers. It's quick & easy.

Newbi needs a very small help, thank you very much.



Newbi needs a very small help, thank you very much.
Hello everyone and thank you very much for your time.

I Have a small db for invoicing and on my form (with a subform) there
is a CANCEL button which will just cancel what had been selected or
entered in the form ... here is the code behind the cancel button...
Private Sub Cancel_Click()

Me![BillsFormSub].Form.Refresh

DoCmd.SetWarnings False

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

DoCmd.SetWarnings True
Exit_Cancel_Click:
Exit Sub
End Sub
This was working fine for many years until just recently where I
upgraded to Windows XP with SP3 Off XP 2003 and the Access 2002
format. (from Off97)

And now everytime someone clicks the cancel button, I get an error
3021 code, and my bill goes up by one bill number.

I would very much appriciate if you could give me and example of a
code replacement for this cancel action that would work in my case.

Sincerely yours,

Mohammad Reza.

P.s in the meantime I have replaced the above two lines with:

DoCmd.RunCommand acCmdDeleteRecord

and it seems it will delete the record as I want it with no error
messege, but now the problem is that the form is advancing to a new
record even thought the current one is also empty.

If I close and reopen the form though, everything is fine.

I tried pressing ESC twice, and using all sorts of DIRTY UNDO REFRESH
and REQUERY commands all to no use, the only way now to get to the
last record is to close and reopen the form, any ideas?

Aug 1 '07 #1
1 1340
On Aug 1, 3:14 am, 6655...@gmail.com wrote:
Newbi needs a very small help, thank you very much.

Hello everyone and thank you very much for your time.

I Have a small db for invoicing and on my form (with a subform) there
is a CANCEL button which will just cancel what had been selected or
entered in the form ... here is the code behind the cancel button...

Private Sub Cancel_Click()

Me![BillsFormSub].Form.Refresh

DoCmd.SetWarnings False

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

DoCmd.SetWarnings True

Exit_Cancel_Click:
Exit Sub
End Sub

This was working fine for many years until just recently where I
upgraded to Windows XP with SP3 Off XP 2003 and the Access 2002
format. (from Off97)

And now everytime someone clicks the cancel button, I get an error
3021 code, and my bill goes up by one bill number.

I would very much appriciate if you could give me and example of a
code replacement for this cancel action that would work in my case.

Sincerely yours,

Mohammad Reza.

P.s in the meantime I have replaced the above two lines with:

DoCmd.RunCommand acCmdDeleteRecord

and it seems it will delete the record as I want it with no error
messege, but now the problem is that the form is advancing to a new
record even thought the current one is also empty.

If I close and reopen the form though, everything is fine.

I tried pressing ESC twice, and using all sorts of DIRTY UNDO REFRESH
and REQUERY commands all to no use, the only way now to get to the
last record is to close and reopen the form, any ideas?
If you are trying to undo changes to a record that has not yet been
saved,

Private Sub Cancel_Click()

Me.Undo

End Sub

should work.

Bruce

Aug 3 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by mickey | last post: by
9 posts views Thread by Christoffer T | last post: by
2 posts views Thread by Amadelle | last post: by
191 posts views Thread by Xah Lee | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.