PDA

View Full Version : Solved: Ocx Calendar Control not Opening with Current Date



coliervile
02-22-2008, 04:00 PM
I have a calendar control to select the date on the userform in "Quick Search For Leave By Date" command button to select the search date. When the calendar opens it always open on June 2007...is there a reason why it's frustrating? Also are there some better calendars to use...it doesn't matter if they are single click or double click?

Best regards,

Charlie

coliervile
02-22-2008, 04:32 PM
Is there a way to adapt DRJ KB http://www.vbaexpress.com/kb/default.php?action=13&kb_id=21 to what I need?

Best regards,

Charlie

coliervile
02-22-2008, 08:35 PM
I've gotten the calendars to load and unload correctly in the different userforms, but I still can't figure out why the calendars only open up on June of 2007??? Can anyone on help me figure out why the calendars open this way and can it be corrected so that the calendars open up on current day, month and year??? :help :bug: :beg:

Best regards,

Charlie

gwkenny
02-22-2008, 11:27 PM
That's easy. It always opens to June 2007 cause that's the value set on the ocxCalendar in design view and you never change the value when you "initialize" the form.

For example, if you want to set the default date to today's date with your Start Date textbox double click event... You would:



Private Sub txtStart_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Load frmCalendar
frmCalendar.ocxCalendar.Value = Now()
....


Computers are pretty stupid, you've got to tell it everything

jammer6_9
02-23-2008, 12:52 AM
On the userform where you have attche the calendar simply input the code below.


Private Sub UserForm_Initialize()
ocxCalendar.Value = Now()
End Sub

coliervile
02-23-2008, 01:41 AM
Thanks to you both for responding. Both ideas worked great thanks for your help. It was driving me nut's trying to figure this out. When I was looking calendars up on the internet I didn't come across any reference talked about adjusting the calendar to the current date (=Now). Thanks again. :beerchug:

Best regards,

Charlie

mdmackillop
02-23-2008, 06:57 AM
Computers are pretty stupid, you've got to tell it everything
Yes, but only once. How often do you have to tell the Users?

coliervile
02-23-2008, 07:18 AM
I'm going to have to start taking some courses on Excel either online or local college so that I can hopefully get smarter than the computer and/or program (Excel)...LOL. Excel is such a useful tool, but there's about a 1000 ways to skin-a-cat (solve a problem).

Best regards,

Charlie

gwkenny
02-23-2008, 07:51 PM
Yes, but only once. How often do you have to tell the Users?

lol, that's why I work a lot more with computers than people!!!

:D

RonMcK
02-23-2008, 08:34 PM
I'm going to have to start taking some courses on Excel either online or local college so that I can hopefully get smarter than the computer and/or program (Excel)...LOL. Excel is such a useful tool, but there's about a 1000 ways to skin-a-cat (solve a problem).

Best regards,

Charlie
Charlie,

You can do a lot of learning on your own. Check your local library (or bookseller [online | local ]) for texts on Excel and VBA. An author I've found helpful is John Walkenbach; I notice that he's now editing a series of texts authored by other folk. You can learn a lot by reading, both generally and looking up specific points. Then, read this website, see what others are asking. See if you know the answer. Attempt to apply things from both here and from books, ask more questions.

Anyway, after you've worked with Excel a bit, you'll know to type =now() when you want the date/time now.

lucas
02-23-2008, 09:43 PM
next problem Charlie......portability.....everyone you send it to must have the calendar control installed.

coliervile
02-24-2008, 04:39 AM
I've learned an awful lot from using VBA Express and Mr. Excel. I've always appreciated every person that have taken the time to explain why this formula does this or why this macro does that. I've gotten some books on the subjects and researched the internet a lot also to find various reading materials. My learning curve is a bit slower when it comes to writing macros, but hopefully the light bulb will come on and it will eventually come more easily. LOL To all of you that helped me as well as others my hats off to you and thanks for you for your patience. :friends: I'm sure there have been times when one of the Site Administrators, Moderators and coders have thought this guy is dumber than a bucket of hair, but I do appreciate your time and patience. Thanks again to all of you.

Best regards,

Charlie :mbounce2:
</IMG></IMG>

coliervile
02-24-2008, 04:46 AM
Thanks "lucas" for that information. I wasn't necessarily going to send this out...the worksheet was designed to put on a computer at work for others to use, but I'll make sure the computer I put this on has calendar control installed. See just another lesson learned. Do all calendars need the calendar control installed? Thanks again.

Best regards,

Charlie

jammer6_9
02-24-2008, 05:16 AM
I use to encounter the same issue but I have found solution. I use to zip a file including "MSCAL.OCX" which is the calendar make a batch file to update the system of each user if they don't have it. Somehow it works :whistle: ... You can try it... Or maybe EXPERTS here can guide us how to cal a batch file from VBA if it's possible...

Find attache...