fat controller
Slightly round the bend..
- Local time
- Today, 16:43
- Joined
- Apr 14, 2011
- Messages
- 758
I have a small piece of code (below), which generally does exactly what I want it to do, however the .setfocus line seems to be being ignored no matter where I put it?
The code was originally:
To see if shifting the code further on did anything, I tried the following
However the end result is the same - - regardless of whether the Update event is triggered by tabbing out of the field, or by clicking on another field, the code executes with the exception of the line to set focus back to the original field, and the focus will go on to the field that was clicked (or the next one in the tab order)
Any clues?
The code was originally:
Code:
Dim DatePicked
DatePicked = txtPerStartDate.Value
If Weekday(DatePicked) <> vbSaturday Then
MsgBox ("All of our four week periods begin on a Saturday, and the date you entered is not a Saturday" & vbLf & vbLf & "Please check the period start date and try again"), vbOKOnly, "Oops! Wrong date entered..."
Me.txtPerStartDate.Value = Null
Me.txtPerStartDate.Setfocus
Else
DoCmd.RunCommand acCmdSaveRecord
Me.cboW1MonDuty.SetFocus
End If
End Sub
To see if shifting the code further on did anything, I tried the following
Code:
Dim DatePicked
DatePicked = txtPerStartDate.Value
If Weekday(DatePicked) <> vbSaturday Then
MsgBox ("All of our four week periods begin on a Saturday, and the date you entered is not a Saturday" & vbLf & vbLf & "Please check the period start date and try again"), vbOKOnly, "Oops! Wrong date entered..."
Me.txtPerStartDate.Value = Null
GoTo Whatnext
Else
DoCmd.RunCommand acCmdSaveRecord
Me.cboW1MonDuty.SetFocus
End If
Whatnext:
Me.txtPerStartDate.SetFocus
End Sub
However the end result is the same - - regardless of whether the Update event is triggered by tabbing out of the field, or by clicking on another field, the code executes with the exception of the line to set focus back to the original field, and the focus will go on to the field that was clicked (or the next one in the tab order)
Any clues?