Requery ONLY works in timer 0.5 sec later !!!

6

6655326

Hello everyone and thank you for your time,



I have a simple form with a subform with a CANCEL button on it. The
problem is that if I don't use the DoCmd.Requery command, the form
advances to the next record even though the previous one was still
empty. If I put the DoCmd.Requery on the bottom or the top of the
Cancel code it dose not work, the ONLY way I have my form working
properly at the moment is like so....



Private Sub Cancel_Click()


Me.TimerInterval = 500
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True


End Sub




Private Sub Form_Timer()

DoCmd.Requery
End Sub




This has solved my problem and everything is ok, it's just that I'm
not feeling comfortable using Timer event and would appreciate if
someone could tell me what my problem is and how to put that requery
command on the cancel button.



Thanking you all in advance.
 
K

Klatuu

It isn't that clear what you are trying to accomplish.
If you are trying to cancel a new record before it is appended to the form's
recordset or cancel changes made to an existing record, what you want is:
Me.Undo
This causes the current record to revert to its state when it became the
current record. For existing records, all the changes will be replaced by
their previous values. For new records, All data entered will be removed
and the form will no longer be Dirty.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top