Hi all
I have a combo-box control [Insertion] which I've set as a required field. It's a date and uses a calendar as coded below. All works fine unless the user deletes a pre-existing value (leaving a 0-length string I guess) and then clicks in the Insertion control.
This results in Runtime error '2110' with the message that "can't move the focus to the control Calendar0"
I think this is because I've made Insertion a required field - certainly the problem is "resolved" if I make Insertion not required.
But I do want it to be a required field...any ideas? I did try loading a default value (today's date) into the field after MouseDown if the value was null or zero length string but that didn't work and anyway I don't like the idea of deliberately putting a false value into the field.
Access 2003, Windows XP
-
Private Sub Insertion_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
Calendar0.Visible = True
-
Calendar0.SetFocus
-
If Not IsNull(Insertion) Then
-
Calendar0.Value = Insertion.Value
-
Else
-
Calendar0.Value = Date
-
-
End If
-
End Sub
-
Private Sub Calendar0_Click()
-
If Calendar0.Value > Date Then
-
MsgBox "Insertion Date cannot be in the future."
-
Calendar0.SetFocus
-
Calendar0.Value = Date
-
ElseIf Calendar0.Value < Me.Parent.DOB Then
-
Call MsgBox("Insertion Date cannot Precede Date of Birth", , "NICU Line Infection Database")
-
Calendar0.SetFocus
-
Calendar0.Value = Me.Parent.DOB
-
Else
-
Insertion.Value = Calendar0.Value
-
Insertion.SetFocus
-
Calendar0.Visible = False
-
End If
-
End Sub
-
Thanks - Michael