473,385 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Calendar Option for Date field

hello everyone!
I would like to add a calenda option onto the form next to the Date field, so that user can just select the date from the calendar instead of typing the date, can someone help?

thanks!
bluemoon
Oct 14 '08 #1
15 2306
NeoPa
32,556 Expert Mod 16PB
When using the Toolbox toolbar (Form design) there is an option at the end called "More Controls". In there you should find a standard one called "Calendar Control n.n".
Oct 14 '08 #2
thanks! but then I would like to hide the calenda until user click on a little button next to the Date field. I was thinking of add a command button next to the Date field, when user click on the command button, calenda open as a dialog form. Does it work that way? is there any other better way, since I have about 10 date fields, I would have to make 10 pop up dialog forms.

thanks!
bluemoon
Oct 14 '08 #3
Hi,
What I did was I put the calenda next to the Date field and set Visible=No, then I put a command button next to the date field, when user click on the command button, I made the calenda visible=true, but then I don't know how to make the calenda visibile=false when user is done with date selection.

thanks!

bluemoon
Oct 14 '08 #4
NeoPa
32,556 Expert Mod 16PB
How about setting up an AfterUpdate event procedure for the control that is being set by the Calendar control. When that runs it can set the Calendar control back to invisible.

You could even make the showing of it triggered by entering the other control (On Enter) instead of having to add loads of Command Buttons.

Sound like an idea?
Oct 14 '08 #5
NeoPa,
You mean to add the code "me.calenda.visible=false" onto the AfterUpdate of the DateField? I did that but it did't really work.
In the calenda Event Property, it only has 5 events: On Updated, On enter, On Exit, On Got Focus and On Lost Focus, I've tried them all and nothing works. Please help.

thanks!
Bluemoon
Oct 14 '08 #6
NeoPa
32,556 Expert Mod 16PB
NeoPa,
You mean to add the code "me.calenda.visible=false" onto the AfterUpdate of the DateField? I did that but it did't really work.
I do mean that. In what way do you mean it didn't work.
Oct 14 '08 #7
I do mean that. In what way do you mean it didn't work.
well, once I selected the date from the calenda, I hit enter key in the keyboard to select the date, the selected date appear in the DateField box, but then the calendar still visible.

thanks alot for your help.
bluemoon
Oct 14 '08 #8
NeoPa
32,556 Expert Mod 16PB
Can you post all the code you have for the controls involved?
Oct 14 '08 #9
Can you post all the code you have for the controls involved?
Yup, here is the code.
My form has a field call txtDate. I place a small cmdCal next to the txtDate field and the calendar next to the cmdCal button, but calendar is set to Visible=No (in the property). When user click on the cmdCal, Calendar is set to visible=true, then user choose a date, then hit enter, the selected date appears in the txtDate box, then I want the calendar to be invisible.

here is my code
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdCal_Click()
  2. Me.Calendar.Visible = True
  3. End Sub
  4.  
  5. Private Sub txtDate_AfterUpdate()
  6. Me.Calendar.Visible = False
  7. End Sub
thanks alot!
bluemoon.

if you have any other idea, please advise. basicly, I just need to have a pull-up calendar for the date fields, that's all.
Oct 14 '08 #10
itchysf
31
You could try this code, the txtbox is changed to a combobox when it is clicked on the calendar becomes visiable and the date can be selected which goes into the combobox and calendar becomes invisable. I have called the combobox (startdate), you can change that to what ever suits you.



Expand|Select|Wrap|Line Numbers
  1. Private Sub StartDate_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2.  
  3. ' Unhide the calendar and give it the focus
  4.     Calendar4.Visible = True
  5.    Calendar4.SetFocus
  6. ' Match calendar date to existing date if present or today's date
  7.     If Not IsNull(StartDate) Then
  8.        Calendar4.Value = Date
  9.     Else
  10.        Calendar4.Value = StartDate.Value
  11.     End If
  12.  
  13. End Sub
  14.  
  15. Private Sub Calendar4_Click()
  16. ' Copy chosen date from calendar to originating combo box
  17.    StartDate.Value = Calendar4.Value
  18. ' Return the focus to the combo box and hide the calendar
  19.    StartDate.SetFocus
  20.    Calendar4.Visible = False
  21.  
  22. End Sub
  23.  
Hope this helps
Oct 15 '08 #11
NeoPa
32,556 Expert Mod 16PB
Try :
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdCal_Click()
  2.     Me.Calendar.Visible = True
  3. End Sub
  4.  
  5. Private Sub Calendar_AfterUpdate()
  6.     Me.Calendar.Visible = False
  7. End Sub
Hopefully that will work. I'm not sure why your code didn't but I can't test it from here.
Oct 15 '08 #12
NeoPa
32,556 Expert Mod 16PB
Also, look at Itchy's code. Although i wouldn't use the events he's used, there is some code in there that could add to the friendliness of your app. Worth nicking I would say ;)
Oct 15 '08 #13
Thank you!

bluemoon
Oct 15 '08 #14
You could try this code, the txtbox is changed to a combobox when it is clicked on the calendar becomes visiable and the date can be selected which goes into the combobox and calendar becomes invisable. I have called the combobox (startdate), you can change that to what ever suits you.



Expand|Select|Wrap|Line Numbers
  1. Private Sub StartDate_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2.  
  3. ' Unhide the calendar and give it the focus
  4.     Calendar4.Visible = True
  5.    Calendar4.SetFocus
  6. ' Match calendar date to existing date if present or today's date
  7.     If Not IsNull(StartDate) Then
  8.        Calendar4.Value = Date
  9.     Else
  10.        Calendar4.Value = StartDate.Value
  11.     End If
  12.  
  13. End Sub
  14.  
  15. Private Sub Calendar4_Click()
  16. ' Copy chosen date from calendar to originating combo box
  17.    StartDate.Value = Calendar4.Value
  18. ' Return the focus to the combo box and hide the calendar
  19.    StartDate.SetFocus
  20.    Calendar4.Visible = False
  21.  
  22. End Sub
  23.  
Hope this helps
Hi,
I used your code and it worked just fine. But there is only one problem left. When I click select TODAY DATE from the calenda, it gave me the date of 12/30/1899 in my Date box. And this happend only the first round. For example, if I select TODAY DATE on the calendar, it gave me the date of 12/30/1899, then I reselect, it gave me the correct date of (10/15/2008). Any idea why? I have no clue why it happended that way.

thanks!
bluemoon
Oct 15 '08 #15
itchysf
31
Hi,
I used your code and it worked just fine. But there is only one problem left. When I click select TODAY DATE from the calenda, it gave me the date of 12/30/1899 in my Date box. And this happend only the first round. For example, if I select TODAY DATE on the calendar, it gave me the date of 12/30/1899, then I reselect, it gave me the correct date of (10/15/2008). Any idea why? I have no clue why it happended that way.

thanks!
bluemoon

In the properties for the calendar, check what is set for the value field(third last field under All tag). Set it to a recent date date.
Oct 16 '08 #16

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Fendi Baba | last post by:
The function is called from opencalendar(targetfield). Thanks for any hints on what could be the problem. .............................................................. var...
19
by: Stimp | last post by:
preferably one that when clicked can update three date dropdowns (day, month, year) like http://www.visitdublin.com/carhire/avis.asp Don't mind paying for the file... anyone seen something...
1
by: Lumpierbritches | last post by:
I have a Calendar control (me.mycal) and a subform sbfAppointments, with child/parent links from Parent/MyCal (ActiveX) to Child/ApptDate in the subform sbfAppointments. I would like to be able...
0
by: jphelan | last post by:
After opening and clicking on the popup calendar command control button, "fdlgCal"; I click on a given date. The date is suppose to then appear in a date field next to the control. Instead, I get...
6
by: caine | last post by:
I have a clickable calendar, which user can select the day that they want to view the news linking to. My calendar has the clickable event day, but once the user click it, the day selected could...
3
by: thorpk | last post by:
I posted this problem earlier in the month and some one decided it was better to change the subject and ask a completely different question. I am therefore reposting. I am hoping some one can...
1
by: EyeHawk | last post by:
OK, hopefully somebody can help me out again. My next problem is updating 3 form fields (type list/menu option) that correspond to a date, one for month, one for day and one for year when the user...
0
by: mathewgk80 | last post by:
HI all, I am having popup calendar Javascript code. But i dont know how it is connecting to asp.net code.. I am using asp.net,c#.net and also using 3tier architecture with master page.... I...
1
by: swethak | last post by:
Hi, I am desiging the calendar application for that purpose i used the below code. But it is for only displys calendar. And also i want to add the events to calendar. In that code displys the...
1
by: swethak | last post by:
hi, i have a code to disply the calendar and add events to that. It works fine.But my requirement is to i have to disply a weekly and daily calendar.Any body plz suggest that what modifications i...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.