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

How to capture date from the calendar into text box?

Status
Not open for further replies.

awinnn

MIS
Jul 21, 2003
166
0
0
MY
Hi,
I have 2 textbox for StartDate and EndDate. Is it possible to have 2 calendar whereby date selected on 1st calendar will stored into StartDate and date on 2nd calendar will stored into EndDate?
Any idea?
Thanx..:)
 
If you add a reference to Microsoft Common Controls 6.0 into your application (first click the Code button to get into the VBA editor then click Tools>References). There are three of them and I can't remember which one you need but it doesn't do any harm to include them all. Then just add the controls to the form (you have to click on the little Additional Tools icon on the toolbar then scroll down until you find it) and call them StartDate and EndDate. You can refer to them in the code just the same as if you were using a text box.

PeteJ
(Contract Code-monkey)

It's amazing how many ways there are to skin a cat
(apologies to the veggies)
 
Hi,
Thanx for the info..
I have 2 unbound textbox and 2 calendar. Is it possible to display selected date on calendar at the unbound textbox?
Thank you.
 
use the on click event for the calender.This event is available only in the forms code module

me.Yourtxtboxname=me.Yourcalendername.value
 
Hi,
I've added the code into calendar's On_Enter() event. But why my textbox display current date? not the date that i've entered?
Any idea? thanx..:)
 
BeeJay57's code line should work fine. I think maybe you should have it in the _Change() event? The following works in my code
Code:
Private Sub DTPicker_Change()

    txtDate = DTPicker

End Sub

PeteJ
(Contract Code-monkey)

It's amazing how many ways there are to skin a cat
(apologies to the veggies)
 
Hi,
may i know..where do i get DTPicker in Ms Access 2000?
TQ..
 
PeteJ,
FYI,
there's no Change() event..but it has Updated() event.
I already tested it..but it doesn't work. Any idea?
Thanx..:)
 
use the on click event for the calender.This event is not listed in the controls events,it is only available in the forms code module.
When in the code module select the calender from the list on the lhs,then select click from the rhs list
 
awinnn, the code snippet in my last post is an actual cut & paste from working code so there must be a _Change() event. Are we looking at a different version of the control? I'm using the one from Microsoft Common Controls 6.0 - the object class is MSComCtl2.DTPicker.2 so if you go into Tools>References and do a browse for MSComCtl2 and select it then you should have the same events as mine.

There is also an _Updated() event where you should put the same line of code because you can key in the value without the drop-down calendar. You can trap the _Click() event but I think it will only show you the current value since it fires before the calendar is displayed for change.

PeteJ
(Contract Code-monkey)

It's amazing how many ways there are to skin a cat
(apologies to the veggies)
 
Why dont you try the after update event

If I take a peek in your Windows, to fix a problem, does that make me a "Peeping Tom"? Hmmmmmmmmmmv [pc1][shocked]
 
It's amazing how many ways there are to skin a cat
(apologies to the veggies)-Your not kidding!!!
Thats why these forums are so good,there are so many different ways to do things in access.
Anyway heres my last thought for this thread
If you use the click event,and have your txt boxes locked,all the user has to do is make a mouse click on the date that they want.That date will be transfered to your txt boxes.Your program does not need to worry about the user accidently keying in an invalid date or format which may cause other problems for your program or error messages that may confuse the user
 
Just to chime in here, I think this must be a common area of confusion when using ActiveX controls (at least it was/is for me!). As I understand it, when you place an ActiveX control and view its property sheet, you're looking at the control's "wrapper" - the interface between the control and Access, so to speak. So the events, you see listed are not necessarily the events available to the control. In fact, to avoid name conflicts with the wrapper, the events in the control itself are generally NOT the same as those displayed in the property sheet. And in my limited experience, trying to hang code on the wrapper's events produces sometimes unpredictable and undesirable results.

So, how to find out what properties, methods, and events are actually available to the control? Documentation in some cases. Another good source is the Object Browser in the VBE window. For instance, to find the goodies in the Date Time Picker, scroll down in the Classes list on the left side of the Object Browser and click on DTPicker. If you're very, very fortunate, you can right click on one of the members of a class, select "Help" from the popup menu, and actually get to a help file. And as Beejay suggested, in the VBE code window, selecting the control from the left dropdown will reveal its events, methods, and properties in the right-hand dropdown (and the events of the wrapper, too).

Also, to access the ActiveX control's properties, from the control's property sheet, the "All" tab, scroll down and find the "Custom" field, click in it, then click on the 3-dot button to the right of the field. Many ActiveX controls will then popup their own custom property sheet.

Caveat: I don't claim to know everything (or even a lot!) about ActiveX. Just some meanderings from my bit of experience...

HTH

Ken S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top