S
Sandy
I have a form "New Jobs" with a subform "NewJobsSubform", the container for
the subform is named "NJSubform".
On the form I have 10 controls in total the final two being
"txtDateOrdered" - bound to "DateOrdered", and "txtDateRequired" - bound to
"DateRequired" in a query. After the date is entered in "txtDateRequired"
pressing the tab key moves the focus to textbox "RepairWhat" in my subform.
All good and well.
I thought to simplify data entry I would introduce a pop-up calendar for
each of my date fields - here is my code (with a great deal of help from the
web!).
Private Sub txtDateOrdered_Enter()
Calendar3.Visible = True
Calendar3.SetFocus
If Not IsNull(txtDateOrdered) Then
Calendar3.Value = txtDateOrdered.Value
Else
Calendar3.Value = Date
End If
End Sub
Private Sub Calendar3_Click()
txtDateOrdered.Value = Calendar3.Value
txtDateRequired.SetFocus
Calendar3.Visible = False
Calendar4.Visible = True
End Sub
Private Sub Calendar4_Click()
txtDateRequired.Value = Calendar4.Value
Forms![New Jobs]!NJSubform.Form!RepairWhat.SetFocus
'Calendar4.Visible = False
End Sub
The first two Subs - "Private Sub txtDateOrdered_Enter()" and "Private Sub
Calendar3_Click()" - works fine the calendar appears when the
"txtdateOrdered" is entered and a selection can be made. The focus then
shifts to "txtDateRequired" and the second calendar "calendar4" appears, (I
know that from checking in design view).
When I now select a date from the calendar it is inserted but I get an error
message saying :-
"Run-time error '2165':
You can't hide a control that has the focus"
I thought the line "Forms![New Jobs]!NJSubform.Form!RepairWhat.SetFocus"
already had reset the focus?!?
Any suggestions?
Sandy
the subform is named "NJSubform".
On the form I have 10 controls in total the final two being
"txtDateOrdered" - bound to "DateOrdered", and "txtDateRequired" - bound to
"DateRequired" in a query. After the date is entered in "txtDateRequired"
pressing the tab key moves the focus to textbox "RepairWhat" in my subform.
All good and well.
I thought to simplify data entry I would introduce a pop-up calendar for
each of my date fields - here is my code (with a great deal of help from the
web!).
Private Sub txtDateOrdered_Enter()
Calendar3.Visible = True
Calendar3.SetFocus
If Not IsNull(txtDateOrdered) Then
Calendar3.Value = txtDateOrdered.Value
Else
Calendar3.Value = Date
End If
End Sub
Private Sub Calendar3_Click()
txtDateOrdered.Value = Calendar3.Value
txtDateRequired.SetFocus
Calendar3.Visible = False
Calendar4.Visible = True
End Sub
Private Sub Calendar4_Click()
txtDateRequired.Value = Calendar4.Value
Forms![New Jobs]!NJSubform.Form!RepairWhat.SetFocus
'Calendar4.Visible = False
End Sub
The first two Subs - "Private Sub txtDateOrdered_Enter()" and "Private Sub
Calendar3_Click()" - works fine the calendar appears when the
"txtdateOrdered" is entered and a selection can be made. The focus then
shifts to "txtDateRequired" and the second calendar "calendar4" appears, (I
know that from checking in design view).
When I now select a date from the calendar it is inserted but I get an error
message saying :-
"Run-time error '2165':
You can't hide a control that has the focus"
I thought the line "Forms![New Jobs]!NJSubform.Form!RepairWhat.SetFocus"
already had reset the focus?!?
Any suggestions?
Sandy