Consulting

Results 1 to 14 of 14

Thread: Solved: Ocx Calendar Control not Opening with Current Date

  1. #1
    VBAX Expert
    Joined
    May 2006
    Location
    Oklahoma City, OK
    Posts
    532
    Location

    Solved: Ocx Calendar Control not Opening with Current Date

    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

  2. #2
    VBAX Expert
    Joined
    May 2006
    Location
    Oklahoma City, OK
    Posts
    532
    Location
    Is there a way to adapt DRJ KB http://www.vbaexpress.com/kb/default...on=13&kb_id=21 to what I need?

    Best regards,

    Charlie

  3. #3
    VBAX Expert
    Joined
    May 2006
    Location
    Oklahoma City, OK
    Posts
    532
    Location
    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???

    Best regards,

    Charlie

  4. #4
    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
    ___________________________________
    g-
    gwkenny@Fin-ITSolutions.com
    ___________________________________

  5. #5
    VBAX Mentor jammer6_9's Avatar
    Joined
    Apr 2007
    Location
    Saudi Arabia
    Posts
    318
    Location
    On the userform where you have attche the calendar simply input the code below.

    [VBA]
    Private Sub UserForm_Initialize()
    ocxCalendar.Value = Now()
    End Sub

    [/VBA]
    T-ogether
    E-veryone
    A-chieves
    M-ore


    One who asks a question is a fool for five minutes; one who does not ask a question remains a fool forever.

  6. #6
    VBAX Expert
    Joined
    May 2006
    Location
    Oklahoma City, OK
    Posts
    532
    Location
    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.

    Best regards,

    Charlie

  7. #7
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Quote Originally Posted by gwkenny
    Computers are pretty stupid, you've got to tell it everything
    Yes, but only once. How often do you have to tell the Users?
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  8. #8
    VBAX Expert
    Joined
    May 2006
    Location
    Oklahoma City, OK
    Posts
    532
    Location
    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

  9. #9
    Quote Originally Posted by mdmackillop
    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!!!

    ___________________________________
    g-
    gwkenny@Fin-ITSolutions.com
    ___________________________________

  10. #10
    VBAX Expert
    Joined
    Aug 2007
    Location
    Windermere, FL, a 'burb in the greater Orlando metro area.
    Posts
    567
    Location
    Quote Originally Posted by coliervile
    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.

  11. #11
    VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    next problem Charlie......portability.....everyone you send it to must have the calendar control installed.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  12. #12
    VBAX Expert
    Joined
    May 2006
    Location
    Oklahoma City, OK
    Posts
    532
    Location
    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. 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
    </IMG></IMG>

  13. #13
    VBAX Expert
    Joined
    May 2006
    Location
    Oklahoma City, OK
    Posts
    532
    Location
    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

  14. #14
    VBAX Mentor jammer6_9's Avatar
    Joined
    Apr 2007
    Location
    Saudi Arabia
    Posts
    318
    Location
    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 ... 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...
    T-ogether
    E-veryone
    A-chieves
    M-ore


    One who asks a question is a fool for five minutes; one who does not ask a question remains a fool forever.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •