Link to home
Create AccountLog in
Avatar of ReefIT
ReefIT

asked on

To hide the Calendar Control when it losses focus.

Hi All,

I have an Access 2003 app and I am experimenting with the Calendar Control 11.

When the calendar control (calDOB) losses focus I want to hide it. (i.e calDOB.Visible = false)
If I put Me.calDOB.Visible = False in the 'On Exit' event of the calendar control, you can't remove focus from the control at all.
If I put the same line into the 'On Lost Focus' event of the calendar control, the focus moves onto the next control but the calendar is still visible.

The only way I seem to be able to accomplish this is to put me.calDOB.visible = false into the 'Got Focus' event of all the other controls on the form. This is obviously messy.

Is there a better way?.

Thanks
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

hi ReefIT

I assume calDOB is hidden by default and is made visible on an event from another control (eg an Enter into a text box).
A further assumption is that the user will select a date from calDOB which will populate another control - why not just pass focus to that field OnClick from calDOB, and then make calDOB.Visible = False?
'Is there a better way?.'

No, unless you are prepared to direct the user to a specific control after they have left the calendar.
(In which case you only have to add the 'messy' code to that control.)
Sould be in the on click of the calendar

Date1.Value = Calendar4.Value
Date1.SetFocus
Calendar4.Visible = False
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer