Can't move the focus

  • Thread starter Thread starter ArtVandele
  • Start date Start date
A

ArtVandele

Guest
I have the following code assigned to a button. This button is suppose to check to insure a Job Number has been entered and if not return a message to the user.

It works great except for....when there is no Job Number the message appears as it should then that message is followed by "Microsoft Access can't move the focus to the control Command56."

This is driving me crazy. What am I missing?

Private Sub Command56_Click()
On Error GoTo Err_Command56_Click

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

If IsNull(Me![QtNum]) Then
MsgBox "A Job Number must be entered to continue."
DoCmd.GoToControl "Command56"
Else

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmViewEstimate"

stLinkCriteria = "[JobID]=" & Me![JobID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

DoCmd.Close acForm, "frmStartJob"

End If

Forms!frmViewEstimate!cmdNext.Visible = False
Forms!frmViewEstimate!cmdPrevious.Visible = False
Forms!frmViewEstimate!Command76.Visible = False

Exit_Command56_Click:
Exit Sub

Err_Command56_Click:
MsgBox Err.Description
Resume Exit_Command56_Click
 
I am not sure what is wrong with your code but try this instead:

Private Sub UnitDesc_Exit(Cancel As Integer)

If IsNull(Me![UnitDesc]) Then
MsgBox ("You must enter a Unit Description")
Me![UnitDesc].SetFocus
Exit Sub
Else
'other stuff
End If

End Sub
 

Users who are viewing this thread

Back
Top Bottom