popup calendar visibility

Zarty

Registered User.
Local time
Today, 08:10
Joined
Jul 4, 2008
Messages
20
I was looking for a solution to enable a popup calendar for two date fields on a form. I found this... http://www.fontstuff.com/access/acctut09.htm
It seems quite good to me and I have a solution working using the suggestion in the article. Essentially, the calendar becomes visible when either of the date field's combo dropdown controls are clicked. Entering a date in the calendar and then clicking anywhere in the calendar causes the data to be written to the originating date field. It also causes the calendar control to becoming invisible. This is all fine but when the calendar control becomes visible, if you click somewhere else on the form like in another field, the calendar then remains visible (until a date is entered). What I want is for the calendar to disappear if you click anywhere else on the form. Can someone suggest a way of doing this?

Thanks,
Zarty
 
Thank you khawar,

The only problem with your solution is that my form has quite a few fields, controls, etc. I would have have events where none exist right now and every field/control would have to be amended to make the calendar control invisible. Is there another way to do it?

Clive
 
Add only this code

Private Sub ocxCalendar_LostFocus()
cboOriginator.SetFocus
ocxCalendar.Visible = False
End Sub


But this will work only when you will click on some control not on the detail or other area of the form
 
Add only this code

Private Sub ocxCalendar_LostFocus()
cboOriginator.SetFocus
ocxCalendar.Visible = False
End Sub

But this will work only when you will click on some control not on the detail or other area of the form

Yes, that makes sense. Unfortunately though, when I tested it, it breaks when I try to add a date to one of the date fields via the calendar control. It actually changes the date but bugs out on cboOriginator.SetFocus ...

Run-time error '2110':
Microsoft Office Access can't move the focus to the control StartDate.

... the following routine...

Private Sub ocxCalendar_Click()
cboOriginator.Value = ocxCalendar.Value
cboOriginator.SetFocus
ocxCalendar.Visible = False
Set cboOriginator = Nothing
End Sub

Any ideas?

Thanks,
Zarty
 
Yes, that works a lot better thank you. Excellent!

Regards,
Zarty
 

Users who are viewing this thread

Back
Top Bottom