Load Calendar value with current date on form open and change with user selection

Posted on 2007-10-18
Last Modified: 2013-11-28
I have a form with an ActiveX Calendar12 object. In control source for the object I have..."=Date()". When my form opens the calendar object loads with the current date like I want it to. I want the user to be able to pick another date and have the value of the object be this new date. As it stands now you cannot select another date and the value is always the current date.
Thanks for the help!
Question by:IronDriver
    LVL 119

    Accepted Solution

    LVL 61

    Expert Comment

    remove the = Date() from the control source.
    Put Date() into the Default value of the field, or of the calendar control itself.

    The user should then be able to select a date.
    LVL 4

    Expert Comment

    If you have no luck finding the default value for the calendar control, remove the control source AND use an On Open Event procedure for the form, this is how I have got aroung this in the past:

    Private Sub Form_Open(Cancel As Integer)

    Me.Calendar0.Value = Date

    End Sub

    LVL 4

    Expert Comment

    sorry that should be:Private Sub Form_Open(Cancel As Integer)

    Me.Calendar0.Value = Date()

    End Sub

    Author Comment

    Curious thing here...I know both capricorn1 and dan's suggestions are effective. I looked at cap's file and is a nice solution. I tried to use dan's code in my current project and cannot get it to work. Yet if I open a new db and build a simple form with just the calendar object and the code it works exactly as I would like. I obviously have something causing the issue in my VB code but haven't found it yet.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
    Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
    The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
    The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now