Command Buttons Not Responding on First Click

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?
 
A

Allen Browne

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.
 
T

thomas.b.mann

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!!
 

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