Cancelling Out of Edit Checks

StacyStacy

A "Californian" at heart!
Local time
Yesterday, 21:09
Joined
Jan 29, 2003
Messages
159
Once I add an edit check to a required field on a form, how do I escape out of that field, and actually, the entire form by hitting the cancel button. I have noticed that I have to enter bogus data, then hit cancel before I can escape out of the field and/or the entire form itself.
 
Pressing the 'Ctrl' 'Z' keys will fire the Windows undo command. You can add an Undo button to your form for your users and use this command...

DoCmd.RunCommand acCmdUndo

HTH
 
I tried that. I didn't work.
 
You can try:
Me.Undo
to cancel out all unsaved changes made to a record. If that doesn't work, please explain more about the error checks you have going on in your form.
 
Here is what I always use for my Undo button and it works when I have required fields...
Code:
Private Sub bUndo_Click()
On Error GoTo Err_bUndo_Click
        
    If Me.Dirty Then
        Beep
        DoCmd.RunCommand acCmdUndo
    Else
        Beep
        MsgBox "There were no modifications made to the current record.", vbInformation, "Invalid Undo"
    End If
    
Exit_bUndo_Click:
    Exit Sub
    
Err_bUndo_Click:
    MsgBox Err.Number & " - " & Err.Description
    Resume Exit_bUndo_Click
    
End Sub
HTH
 
Thank you everyone. I was in a meeting for the rest of the day on yesterday. I will try the code you sent and give a reply.

Merry Christmas! ;))
 
Ok, I tried it. I didn't work. I was still prompted to enter a value. Once I entered a value, then the code worked, just like my original 'cancel' button.

I don't know what to do. Here's what I am trying to accomplish:
When a user opens that particular screen and they immediately want to exit out and return to the menu, they have to enter a value in the first field. I have written code to have the cursor placed in the first field upon opening the form. That first field is a required field as well. Even if they hit the cancel button (my original button and the code you sent) they still have to enter a value in order to cancel their transaction and exit back to the main menu.

I hope this helps. Please let me know.
 
Why don't you create an unbound text box and have the focus set to it when the form is first opened? I always use an unbound text box in my forms that I throw the focus to at the end of most of my forms functions. That way nothing of importance has the focus and the user has to choose [click] what they want to do.

To keep the unbound text box sort of hidden, I place it in the upper left corner and I size it as small as possible like 0" x 0".

HTH
 
Well, that's a good idea, but my user is a little needy. He wants the cursor to fall into the first 'real' field of the form. What do I do then??
 
Without seeing your db I can not guess how to resolve your cancel problem. I would ask the user which is more important... having the first field selected or having to enter dummy info then hitting the escape key just to enter a form that they do not want to enter any new data into.
:D
 
Need Help Again ...

I'm still having problems with this issue. The end user has changed their mind and wants to be able to keep the edit checks and be able to click onto the cancel button without putting bogus information into the first field or any field for that matter, which is a required field.

What do I do?
 

Users who are viewing this thread

Back
Top Bottom