Hide Pop-up Calendar by clicking Outside It

M

Mercadogs

Hello World:

I pray you are doing great today!

My Question:
Is there a way to hide a pop-up calendar whenever the user clicks anywhere
outside of the calendar? Right now, I am using the code below, which whenever
the user clicks on this particular combo box, the calendar is shown. However,
the calendar doesn't disappear unless a date is selected from the calendar.

Beginning of Code:

Private Sub txt_DateCreated_MouseDown(Button As Integer, Shift As Integer, X
As Single, Y As Single)

Set cboOriginator = txt_DateCreated


If Not IsNull(cboOriginator) And cboOrinator <> "" Then
If MsgBox("Are you sure you want to update this date?",
vbYesNoCancel, "Click yes to update " & _
"date...") = vbYes Then
RequestDateCal.Visible = True
RequestDateCal.SetFocus
RequestDateCal.Value = cboOriginator.Value

Else
'txt_Date.SetFocus
End If

Else
RequestDateCal.Visible = True
RequestDateCal.SetFocus
RequestDateCal.Value = Date
End If


End Sub

'''End of Code
 
M

Maurice

I assume the calendar you are using is placed on a form. This form is
probably set to modal and therefore won't hide unless you select a date. This
is the way it is supposed to work. Why would you run the risk of forgetting
to close the calendarform? This could cause problems in other situations. A
solution might be to set the form to not modal that way it can be hidden
behind another form but be aware that this might cause problems in the rest
of your db. I'd advice you to use the current settings...

If I want to give the user an option I place the calendar behind the double
click of the textbox, that way if they want to enter there own option they
can by just tabbing to the control or just click once..

hth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top