[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 461
  • Last Modified:

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

0
bignadad
Asked:
bignadad
1 Solution
 
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
 
bignadadAuthor Commented:
i just deleted the whold thing and inserted a button to do what i needed it to do
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now