Have to Hit Exit Command Button Twice to Exit Form in Access

i have a button on my form that uses a macro to close it

when i click the button the focus goes to txtMake textbox. then i have to click again to actually exit form

code is below from form.
Option Compare Database
 
Private Sub cmdDetails_Click()
    DoCmd.OpenForm "details", , , , , acDialog, OpenArgs:=Me.txtBAM
End Sub
 
Private Sub cmdExit_Click()
    DoCmd.OpenForm "Switchboard"
    DoCmd.Close acForm, "entermachine"
End Sub
 
Private Sub Command43_Click()
    DoCmd.PrintOut acSelection
End Sub
 
Private Sub Command74_Click()
    DoCmd.Close acForm, "entermachine"
    DoCmd.OpenForm "switchboard"
End Sub
 
Private Sub cmdViewPics_Click()
    DoCmd.OpenForm "picture import", acNormal, , , , acDialog
End Sub
 
Private Sub txtSellPrice_Exit(Cancel As Integer)
    txtSellPrice = Format(txtSellPrice, "$#,00.00")
End Sub
 
Private Sub txtSellPrice2_Exit(Cancel As Integer)
    txtSellPrice2 = Format(txtSellPrice2, "$#,00.00")
End Sub
 
Private Sub txtType_Exit(Cancel As Integer)
    If txtType.Text = "Grain Head" Then
        Me.txtFuel.SetFocus
        Me.txtFuel.Text = "N/A"
        Me.txtEngine.SetFocus
        Me.txtEngine.Text = "N/A"
        Me.txtEngineSerial.SetFocus
        Me.txtEngineSerial.Text = "N/A"
        Me.txtFTires.SetFocus
        Me.txtFTires.Text = "N/A"
        Me.txtRTires.SetFocus
        Me.txtRTires.Text = "N/A"
        Me.txtDuals.SetFocus
        Me.txtDuals.Text = "N/A"
        Me.txt4WD.SetFocus
        Me.txt4WD.Text = "N/A"
        Me.txtTrans.SetFocus
        Me.txtTrans.Text = "N/A"
        Me.txtHours.SetFocus
        Me.txtHours.Text = "N/A"
        Me.txtMake.SetFocus
    End If
        Me.txtType.SetFocus
    If txtType.Text = "Corn Head" Then
        Me.txtFuel.SetFocus
        Me.txtFuel.Text = "N/A"
        Me.txtEngine.SetFocus
        Me.txtEngine.Text = "N/A"
        Me.txtEngineSerial.SetFocus
        Me.txtEngineSerial.Text = "N/A"
        Me.txtFTires.SetFocus
        Me.txtFTires.Text = "N/A"
        Me.txtRTires.SetFocus
        Me.txtRTires.Text = "N/A"
        Me.txtDuals.SetFocus
        Me.txtDuals.Text = "N/A"
        Me.txt4WD.SetFocus
        Me.txt4WD.Text = "N/A"
        Me.txtTrans.SetFocus
        Me.txtTrans.Text = "N/A"
        Me.txtHours.SetFocus
        Me.txtHours.Text = "N/A"
        Me.txtMake.SetFocus
    End If
        Me.txtMake.SetFocus
End Sub

Open in new window

LVL 2
bignadadAsked:
Who is Participating?
 
bignadadConnect With a Mentor Author Commented:
i just deleted the whold thing and inserted a button to do what i needed it to do
0
 
puppydogbuddyCommented:
Try commenting out line 75, which will let your code flow through to line 77.  Otherwise, anytime your code executes line 75, it will also execute line 77.....thus setting focus twice.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.