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

How to use Aactive X control calender

Status
Not open for further replies.

Chavito21

Programmer
Mar 26, 2003
230
US
Hi everyone,

I want to have a form where the user can open a calendar and pick a date and that date would shown then on a text box so the user can type the date or pull a calender and pick the date from there. I have two dates that need to be like that. I just find out about Active X Control Calendar control 9.0. but I don't know how to use it the way i want to. I am using Access 2000

So if someone have some info I can use I would appreciated

Thanks
chavito

 
Insert your calendar control (mine was calendar control 10.0) into your form.

Right click the control and select build event/code builder.

Choose the on click event from the dropdown at the top right.

Add this line of code between the two lines that were written for you:

Me.YourFieldName = Me.Calendar0

It should look something like this:

Private Sub Calendar0_Click()
Me.YourFieldName = Me.Calendar0
End Sub

You will need to change "YourFieldName" to the name of the text box that is storing the date value and change "Me.Calendar0" to the name of your calendar control.

HTH,
Eric

 
Here is a thread that I responded to recently. Check it out.

thread702-827192

Also, one of the TekTips experts JimmyTheGreek(Jim Lunde) has developed a great ACCESS form that acts like a Calendar Control and is so very easy to use. No registration of the ActiveX control or anything. If you send me an email(see my profile for address) I will return to you the zip file with both the A97 and the A2K versions.

Good luck.

Bob Scriver
[blue]Want the best answers? See FAQ181-2886[/blue]


 
How are ya Chavito21 . . . .

First you need to see if you have it. In form design view, click MenuBar - Insert - ActiveX Control... Scroll down and see if you have [blue]Calendar Control 9.0[/blue]. If its there, click OK to put it in the form and get a good Idea of how much space it takes (it is sizeable). If its not there you'll have to install it.

Now that you know how much space it takes, you have to decide where to put it.
[blue]Do you have enough space to put it on the same form as your textboxes in question (bearing in mind you may want to add other items at a later time)?
or
Will you have to use another form?[/blue]
Let me know if ya have the Calendar, answer the quote above, and I'll step ya thru it.

cal.gif
See Ya! . . . . . .
 
Hi Aceman - thanks for reply,
In response to your queries:
Yes to first point and
Yes to second point

I have space on main form - but I wnat sub-forms that are connected to Main form to use this Calendar as well - ie one Calendar on main form that feeds 16 date filds spread across one amin form and 6 connected subforms

Hope this helps you

Nicos

 
How about using the PreviousControl property along with the Screen object to direct the Calendar control where to assign the Calendar pick. Like when the focus stops on a date control and you click the calendar control, in the AfterUpdate event procedure of the Calendar control you can put some code in like this:

Code:
Dim ctlPrevious As Control
Set ctlPrevious = Screen.PreviousControl
ctlPrevous = [i]calendardatevalue[/i]
ctlPrevious.Name.SetFocus

The italics entry above would be your calendar controls date value and you have to supply that. The code would set the focus back to the control that you have just left and updated with the date.

Post back if you have any questions.

Bob Scriver
[blue]Want the best answers? See FAQ181-2886[/blue]


 
OK Chavito21 . . . . was wondering what happen to ya!

There's not much to using the Calendar control. In design view, if you right-click the calendar & select [blue]Calendar Object - Properties[/blue], you'll get a tabbed dialog which allows you to set the cosmetics for the control (how you want it too look, what you want on it, fonts & sizes . . .ect). You can make changes and use the [blue]Apply Button[/blue] to see if you tastes are met.

Operational wise, you are of course going to use events of the control, however, the events tab only shows a small portion of whats available. To see and use the ones that don't show: Open the [blue]Form Module[/blue]. DropDown the top-left combobox and select the name of your Calendar Control. In the dropdown list on the right will appear all the events, particularly the [purple]After Update[/purple] event, which is the one you'll use.

In the [purple]After Update[/purple] event you can put the code given by [blue]scriverb[/blue] which readily fits your needs. I've modified the code (see below) only in that I supply the actual date source.
Code:
[blue]Dim ctlPrevious As Control
Set ctlPrevious = Screen.PreviousControl
ctlPrevous = Me![purple][b]YourCalendarName[/b][/purple].Value
ctlPrevious.Name.SetFocus[/blue]
We'll be here if ya need us . . . .

Cheers!

cal.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top