Results 1 to 10 of 10
  1. #1
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Calender control (Access2000)

    I am trying to use the Calender Controls to enter a date range for a report. How can I set a default date in these type of controls?
    Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

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

    Re: Calender control (Access2000)

    If you mean the Microsoft Calendar control, it's an ActiveX control, not an Access control; it doesn't have a DefaultValue property.
    You can set the value of the control in the OnLoad or OnOpen event of the form that contains the control; for instance
    calDateSelect = Date
    if you want to set the value of the calDateSelect control to the current date.

  3. #3
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Calender control (Access2000)

    Thanks for your response Hans, and yes I understand it's an ActiveX control, I just wasn't explicit enough.
    I have the following in the OnOpen event of the form, but it still does not work.
    Dim dteDate As Date
    dteDate = DLookup("[DecidedDate]", "[qry Latest Date Decided]")
    TextDateFrom = dteDate
    where TextDateFrom is the ActiveX control.
    Any ideas why?

    Pat <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>

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

    Re: Calender control (Access2000)

    Hi Pat,

    Your code looks OK. Try putting a breakpoint in the OnOpen event and single-stepping through the code. Does dteDate get assigned the date you expect?

  5. #5
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Calender control (Access2000)

    It sure does. However when the line is executed that sets up the date from dteDate and I look at the value in the ActiveX control in the immediate window there is a blank line.

    I have done this before in Access 97 but I put the code in the OnEnter event of the ActiveX control and that seemed to work.

    This is stumping me, this one.

    I appreciate your help on this one.

    Pat

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

    Re: Calender control (Access2000)

    Sorry, I'm out of ideas here. The calendar controls I have on my system (Microsoft Calendar Control and Microsoft Date and Time Picker Control) both can be set in code OK. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>

  7. #7
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Calender control (Access2000)

    I have been experimenting and have found if I put the code in the OnEnter event of the control and I click at the top of the control it works.
    What I want to do is somehow simulate that in code.
    Any more ideas in light of above? Is there a certain version I should have, I currently have version 7.
    Pat <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>

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

    Re: Calender control (Access2000)

    What happens if you set the value of TextDateFrom in the OnLoad event instead of in the OnOpen event of the form? The OnLoad occurs later in the chain of events.

  9. #9
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Calender control (Access2000)

    Perhaps this will help Patt.

    I changed my Calender controls to what I've included in the attachment.
    It seems to work pretty well for me.
    The only difference I see from your code is only slight but may solve your problem.

    Private Sub calCalendar_Click()
    Me.txtTemp = Me.calCalendar.Value
    End Sub

    Private Sub Form_Load()
    If IsNull(Me.txtTemp) Then
    Me.calCalendar.Value = Date
    Else
    Me.calCalendar.Value = Me.txtTemp
    End If
    End Sub
    Attached Files Attached Files

  10. #10
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Calender control (Access2000)

    Bingo Hans !!
    The OnLoad event seems to be the right event, as Dave also pointed out.
    Thank you for your time and expertise.
    Pat <img src=/S/smile.gif border=0 alt=smile 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
  •