Command Buttons Not Responding on First Click

  • Thread starter Thread starter thomas.b.mann
  • Start date Start date
T

thomas.b.mann

Using Access 2003.

Very simple, I have a command button to close the form. Code is as
follows (form is called "Select212Form")

Private Sub btnMenu_Click()
On Error GoTo Err_btnMenu_Click

DoCmd.Close acForm, "Select212Form"

Exit_btnMenu_Click:
Exit Sub

Err_btnMenu_Click:
MsgBox Err.Description
Resume Exit_btnMenu_Click

End Sub

The button does nothing the first time it's clicked. Next time, I
click it, it works! It's not a double-click, there is a pause between
clicks. If I put a breakpoint in there, it enters the routine on the
first click and closes the form as it should. Anyone every seen this?
 
Is it possible that the form could have unsaved edits that are effecting
things here?

Try replacing:
DoCmd.Close acForm, "Select212Form"
with:
Debug.Print Now() & " - attempting to close " & Me.Name
If Me.Dirty Then Me.Dirty = False
DoCmd.Close acForm, Me.Name

If that works, you can remove the Debug.Print line.
 
I have tried both of those things:

if me.dirty then me.dirty=false

as well as using Me.Name as opposed to "Select212Form"

This form is not even data bound.

However, when I just change the code to simply say:

DoCmd.Close

it seems to work just fine!!
 
Back
Top