Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calendar Control - Visable when form opens

Status
Not open for further replies.

dham63

Technical User
Sep 18, 2008
15
CA
Good Day and thank you in advance for your assistance. I am using Office 2003. As part of a form I have added a calendar pop up (From the control toolbox) which is working well except for one thing. The calendar is visable upon opening the form. I would like the calendar only to appear when the appropriate date field is clicked on. Please find my code below.

Option Compare Database
Option Explicit
Dim Orig As ComboBox

Private Sub Cal1_Click()
CBR.Value = Cal1.Value
CBR.SetFocus
Cal1.Visible = False
End Sub

Private Sub CBR_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Set Orig = CBR
Cal1.Visible = True
Cal1.SetFocus
If Not IsNull(CBR) Then
Cal1.Value = CBR.Value
Else
Cal1.Value = Date
End If
End Sub
 
Placing the following on some event should work for you
Code:
Me.YourCalendarName.visible = true

For reference, if you want a calendar control with considerably more flexibility, but requiring a bit more work,
see I haven't looked there in some years, but they used to have a nice Windows API based sample.

Cheers, Bill
 
How are ya dham63 . . .

In form design view set the calendars [blue]Visible[/blue] property to [blue]No[/blue].

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Thanks so much for the help guys, I will remember the tips for next time. I ended up solving my issue by moving the Cal1_ click routine to the bottom of all the other code. I ended up using a number of date fields to access the one calendar, and all worked well as long as the code for the date field was above the Cal1_click routine.
 
Hello Dham63,

The order in which you place routines (subs and functions) in a module has absolutely no bearing on how the code works. The only convention is to place module or public level constants and variables above subs and functions.

So whatever you did to fix your problem, is was something other than rearranging the order of routines.

Cheers, Bill

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top