Set focus

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I seem to have so much trouble with set focus. Does it trouble anyone else?
Maybe I dont understand what it does or maybe its the if /then I am using. I
have a very simple pop up form. it has 2 enties and I want to be sure that
there is data in those fields before I close the form.
If it detects a null, want it to stop and wait for input at the txtbox. It
doesn't, it just closes form. My guess is the if/then not the set focus but
I hope I will get other opinions.

Private Sub cmdToClosefrmRepairComplete_Click()
On Error GoTo Err_cmdToClosefrmRepairComplete_Click
If IsNull(txtDateRepairComplete) Then
MsgBox (" You must have an Entry in 'Date Repair Complete'")
Me.txtDateRepairComplete.SetFocus

End If



DoCmd.Close

Exit_cmdToClosefrmRepairComplete_Click:
Exit Sub

Err_cmdToClosefrmRepairComplete_Click:
MsgBox Err.Description
Resume Exit_cmdToClosefrmRepairComplete_Click

End Sub

I
 
Put an Exit Sub step right after the SetFocus step. Your code currently sets
the focus and then continues to the Close step.

If IsNull(txtDateRepairComplete) Then
MsgBox (" You must have an Entry in 'Date Repair Complete'")
Me.txtDateRepairComplete.SetFocus
Exit Sub
End If
 
Thanks Ken

Ken Snell said:
Put an Exit Sub step right after the SetFocus step. Your code currently sets
the focus and then continues to the Close step.

If IsNull(txtDateRepairComplete) Then
MsgBox (" You must have an Entry in 'Date Repair Complete'")
Me.txtDateRepairComplete.SetFocus
Exit Sub
End If
 
Back
Top