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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I add a calendar drop-down control to a text box ?

Status
Not open for further replies.

ScorpioMCN

Programmer
Feb 13, 2003
40
US
I have a form in Access 2000 with a date field - I want the user to be able to click a down arrow and bring up a calendar to easily select a date if they would rather not type it in.

I've searched a lot of posts on calendar control but nothing seems to fit my issue and I'm not a code wizard so I need a little hand-holding here.

Would appreciate any help. Thanks.
 
There are several calendars in the FAQ's
Use the on focus event of the textbox to open the calendar form.
This may be ambitious for someone new to coding.


Ian Mayor (UK)
Program Error
Always make your words sweet and nice. Because you never know when you may have to eat them.
 
It's basically just a matter of placing the calendar control where you want it displayed, and setting it's Visible property to false. When the down arrow button is clicked, make the calendar control visible. When the user selects a date, copy the date to the textbox, then make the calendar control invisible again.


 
Joe - that sounds like it would work.

Could you PLEASE tell me how I would code that ??

Thanks so much!
 
I'm confused about the "down arrow" part. What down arrow? A down arrow would be part of a combo box, but not part of a text box.

What I do for this type of thing is, as has already been suggested, place a calendar control on the form, positioned as you like and set it's Visible Proprty to NO.

Then, using the DoubleClick property of your text box, have the calendar "popup" for date selection. You'll need to replace YourCalendarName and YourTextBoxName with the actual names of your calendar and text box.

Code:
Private Sub Form_Load()
  YourCalendarName.Value = Date
End Sub

Private Sub YourCalendarName_Click()
  YourTextBoxName.Value = YourCalendarName.Value  
  YourTextBoxName.SetFocus
  YourCalendarName.Visible = False
End Sub

Private Sub YourTextBoxName_DblClick(Cancel As Integer)
  YourCalendarName.Visible = True
End Sub

Now, all your user has to do is DoubleClick on the text box and up pops the calendar! When the user clicks on the date, the calendar disappears and the text box is populated with the date.

Linq

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
I'm working on a huge app now that currently uses the MS Calendar, but because of the unreliability of ActiveXs, especially between versions, I'm probably going to use the one from Brinkster.

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
You guys are awesome! Thanks so much!

I tried the brinkster method but it errored out - I used the method missinglinq suggested above and it works like a dream!! THANK YOU!!

Happy Camper
:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top