Results 1 to 6 of 6
  1. #1
    4 Star Lounger
    Join Date
    Oct 2003
    Location
    Guelph, Ontario, Canada
    Posts
    428
    Thanks
    0
    Thanked 0 Times in 0 Posts

    open calendar control at Date() (2000 (all updates))

    On an unbound form, I have a Calendar control called ocxCal

    When the form opens I would like the calendar to be set at today's date. However it opens at the last date that was used prior to closing the form. (e.g. this morning it opens with yesterday's date, 11/22/08, selected.

    I have tried putting in the following code to force it to open at today's date.
    <code>Private Sub Form_Load()
    Me!ocxCal.Value = Date
    End Sub</code>

    However that has no effect. Putting the code on the OnOpen event has no effect either.

    The interesting thing is that when you are working in Form Design View and shift to Form View it goes to today's date. But if you open the form from the Main Menu or anywhere else, it goes to the last date used.

    Any suggestions would be appreciated.

    Tom

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: open calendar control at Date() (2000 (all updates))

    It doesn't work for me if I use the On Open event of the form, but it does if I use the On Load event of the form. Are you sure you don't have other code that changes the value of the calendar control?

  3. #3
    4 Star Lounger
    Join Date
    Oct 2003
    Location
    Guelph, Ontario, Canada
    Posts
    428
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: open calendar control at Date() (2000 (all updates))

    Well, any other code that I have for changing values is the pretty common stuff...such as code to go ahead or back a specific number of weeks or months.

    What has been happening is that it has been opening 1 day less than the actual date, regardless of the last date chosen on the calendar, and there is nothing that I can see that would cause that...especially when you shift to Design View and back to Form View and it always resets to the current date. It's only when opening from a Main Menu, or double clicking the form itself that the problem occurred.

    Now, having said that, I commented out all code on the form and then it opened at Date() as it should. So I saved the form, and then began removing the "comment-outs" from pieces at a time, and testing. Finally, I removed all "comment-outs" because no problems showed up. And now the form is opening to Date() as it should.

    It doesn't make sense to me that it's working properly now when it wouldn't before. The acid test will be to open the form tomorrow and see if it performs properly then.

    Prior to doing all of the commenting-out, I had set breakpoints, and nothing ever showed an error.

    It's a blinkin' mystery.

    Tom

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: open calendar control at Date() (2000 (all updates))

    Let us know what happens tomorrow...

  5. #5
    4 Star Lounger
    Join Date
    Oct 2003
    Location
    Guelph, Ontario, Canada
    Posts
    428
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: open calendar control at Date() (2000 (all updates))

    Well, today the form opens with the calendar on the correct date.

    This makes no clear sense to me because I haven't really changed anything. Although it would seem as if commenting out all of the code, saving the form, and then going in and removing the comments made it work properly again.

    Gremlins?

    Tom

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: open calendar control at Date() (2000 (all updates))

    Gremlins! <img src=/S/devil.gif border=0 alt=devil width=15 height=15>

Posting Permissions

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