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
[Code=vb]
Private Sub Insertion_Mouse Down(Button As Integer, Shift As Integer, X As Single, Y As Single)
Calendar0.Visib le = True
Calendar0.SetFo cus
If Not IsNull(Insertio n) 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.SetFo cus
Calendar0.Value = Date
ElseIf Calendar0.Value < Me.Parent.DOB Then
Call MsgBox("Inserti on Date cannot Precede Date of Birth", , "NICU Line Infection Database")
Calendar0.SetFo cus
Calendar0.Value = Me.Parent.DOB
Else
Insertion.Value = Calendar0.Value
Insertion.SetFo cus
Calendar0.Visib le = False
End If
End Sub
[/Code]
Thanks - Michael
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
[Code=vb]
Private Sub Insertion_Mouse Down(Button As Integer, Shift As Integer, X As Single, Y As Single)
Calendar0.Visib le = True
Calendar0.SetFo cus
If Not IsNull(Insertio n) 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.SetFo cus
Calendar0.Value = Date
ElseIf Calendar0.Value < Me.Parent.DOB Then
Call MsgBox("Inserti on Date cannot Precede Date of Birth", , "NICU Line Infection Database")
Calendar0.SetFo cus
Calendar0.Value = Me.Parent.DOB
Else
Insertion.Value = Calendar0.Value
Insertion.SetFo cus
Calendar0.Visib le = False
End If
End Sub
[/Code]
Thanks - Michael
Comment