In the code below, I want this button to disable if data is missing in the 'batchnumber' text box. The setfocus is because I can't disable a button that has the focus. The problem is the script is apparently ignoring my if and running the else. Can anyone see where I messed up?????
Private Sub btnNewKid_Click()
On Error GoTo Err_btnNewKid_Click
If Me!BatchNumber < 1 Then
With PeriodEndDate
.setfocus
with btnNewKid
.Enabled = False
End With
End With
GoTo Exit_btnNewKid_Click
else
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.GoToRecord , , acNewRec
DoCmd.Close acTable, "tblChildMatch", acSaveNo
Me!PeriodEndDate.SetFocus
End If
Exit_btnNewKid_Click:
Exit Sub
Err_btnNewKid_Click:
MsgBox Err.Description
Resume Exit_btnNewKid_Click
End Sub
Private Sub btnNewKid_Click()
On Error GoTo Err_btnNewKid_Click
If Me!BatchNumber < 1 Then
With PeriodEndDate
.setfocus
with btnNewKid
.Enabled = False
End With
End With
GoTo Exit_btnNewKid_Click
else
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.GoToRecord , , acNewRec
DoCmd.Close acTable, "tblChildMatch", acSaveNo
Me!PeriodEndDate.SetFocus
End If
Exit_btnNewKid_Click:
Exit Sub
Err_btnNewKid_Click:
MsgBox Err.Description
Resume Exit_btnNewKid_Click
End Sub