Results 1 to 11 of 11
  1. #1
    2 Star Lounger
    Join Date
    Apr 2003
    Location
    Vail, Colorado, USA
    Posts
    194
    Thanks
    36
    Thanked 0 Times in 0 Posts

    ActiveX Calendar (2000)

    I have a procedure that opens a calendar 91 days before today's date for a date to be selected. However if the date I want to select is exactly todays date -91 I cannot select it. Have tried setting the value of the calndar to Null (also tried Empty) so that date is not highlighted but I still cannot select it. As the date I want to select is always a Sunday I have worked around the problem, but that seems very cumbersome. Can anyone help.

    Thanks
    Peter

    Peter

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

    Re: ActiveX Calendar (2000)

    What do you mean when you say "you can't select it". How do you set the Calender to shaw the Date-91 ? Do you set it in the OnEnter event?
    If it's already highlighted then it's pointing at the correct date.
    I have just tested this by setting up a calender on a form with a text field named textDate. What I did was to setup the calender in the OnEnter event with Date() - 91.
    In the OnLostFocus event of the calender I set the TextDate = calender date.
    This all seems to work just fine.

    Have I been any help at all?

    Pat

  3. #3
    2 Star Lounger
    Join Date
    Apr 2003
    Location
    Vail, Colorado, USA
    Posts
    194
    Thanks
    36
    Thanked 0 Times in 0 Posts

    Re: ActiveX Calendar (2000)

    The calendar is set to invisible when the from is current. A command button makes the calendar visible code below (onclick). The date selected is transferred to an unbound next from in the Afterupdate event of the calendar control. The date selected with the Date-91 may not be correct it is an approximation to get the calendar into the correct month as the report I am producing is quarterly and should therefore have start date about 91 days before todays date. As I mentioned in my earlier post the day has to be a Sunday and because of this the code below includes my workaround which I know is very clumsy.

    Private Sub StartDateDrop_Click()
    StartDateCal.Visible = True
    If Weekday(Date - 91) = 1 Then
    StartDateCal.Value = Date - 90
    Else
    StartDateCal = Date - 91
    End If
    StartDateCal.Value = Empty
    End Sub

    I tried altering mycode so the calendar date was set OnEnter but I cannot trigger the afterupdate event if I try and selectthe date set by date-91. Thanks for your trouble any other suggestions greatly appreciated.

    Thanks

    Peter

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

    Re: ActiveX Calendar (2000)

    Firstly I don't think there is an AfterUpdate event for the Calender control. Also the last statement clears the StartDateCal control.
    I presume that StartDateDrop is a command button.
    What do you get in StartDateCal when you click the button, is it Null?

    What exactly do you wish to do here?

    Pat

  5. #5
    2 Star Lounger
    Join Date
    Apr 2003
    Location
    Vail, Colorado, USA
    Posts
    194
    Thanks
    36
    Thanked 0 Times in 0 Posts

    Re: ActiveX Calendar (2000)

    The AfterUpdate event is certainly not listed in the properties form for the calendar control, like a lot of events that are tied to active x controls. If you select code from the update event and then click on the drop down box in the VB window and scroll though the events you will see a number not listed in the properties box including afterupdate. The code follows.

    Private Sub StartDateCal_AfterUpdate()
    'after a date is selected writes that to the variable StartDate
    StartDate = StartDateCal
    If Weekday(StartDate) > 1 Then
    MsgBox "You did not select a Sunday try again", vbCritical, "MUST BE A SUNDAY"
    GoTo VARIATION
    Else

    FirstWeek = DatePart("WW", StartDate)
    StartDate.SetFocus
    StartDateCal.Visible = False
    'if this control has been accessed again it checks to see if dates now exist for both values
    'if values do exist it calcs the # weeks other wise it ends
    If IsNull(EndDate) Then
    GoTo VARIATION
    Else
    NumberWeeks = LastWeek - FirstWeek
    End If
    End If
    VARIATION:
    End Sub

    I put in the Null statement in the hope that as a date was not slected I could trigger the afterupdate event by selecting one. Which I can as long as it was not the date created when I went to the control namely date-91. Yes the StartDateDrop is a command button. If the date is not the one derived from Date-91 when I select a date (now as long as it is a Sunday) I trigger the AfterUpdate event. This you can see is written to a text box StartDate.

    Thanks again

    Peter

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

    Re: ActiveX Calendar (2000)

    Can you verify that the Private Sub StartDateCal_AfterUpdate() code is in fact executed?
    Try setting a breakpoint and see what happens.

    Pat

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

    Re: ActiveX Calendar (2000)

    Try adding StartDateCal.SetFocus at the end of StartDateDrop_Click. This will make the calendar control the active control.
    Check the value of the calendar in the On Exit event - that will always occur, whether the user has changed the value or not. In the code below, I have added Cancel = True if the selected date is not a Sunday. I have taken out the GoTo VARIATION, since jumping to a label should only be used in error handling statements.

    Private Sub StartDateCal_Exit(Cancel As Integer)
    StartDate = StartDateCal
    If Weekday(StartDate, vbSunday) > 1 Then
    MsgBox "You did not select a Sunday try again", vbCritical, "MUST BE A SUNDAY"
    Cancel = True
    Else
    FirstWeek = DatePart("WW", StartDate, vbSunday)
    StartDate.SetFocus
    StartDateCal.Visible = False
    If Not IsNull(EndDate) Then
    NumberWeeks = LastWeek - FirstWeek
    End If
    End If
    End Sub

  8. #8
    2 Star Lounger
    Join Date
    Apr 2003
    Location
    Vail, Colorado, USA
    Posts
    194
    Thanks
    36
    Thanked 0 Times in 0 Posts

    Re: ActiveX Calendar (2000)

    I set a breakpoint and it brought up the code and I stepped through it so it is working OK.

    Thanks

    Peter

  9. #9
    2 Star Lounger
    Join Date
    Apr 2003
    Location
    Vail, Colorado, USA
    Posts
    194
    Thanks
    36
    Thanked 0 Times in 0 Posts

    Re: ActiveX Calendar (2000)

    I added StartDateCal.SetFocus at the end of StartDateDrop_Click event as you suggested, bu that did not help. Before the calendar had nothing highlighted now there is a frame around the Date-91 but I cannot select it. Cannot check the OnExit event as when I do not select a date (because I cannot it being the date -91) I dont get to exit the calendar.

    Thansk for the tip about Cancel shows you how little I know about access.

    Thanks again any other suggestions would be appreciated.

    Peter

  10. #10
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: ActiveX Calendar (2000)

    Just because an event shows up in the dropdown, that doesn't mean you can use it. ActiveX controls don't necessarily use the events you see in the module dropdown . You need to go to the object browser to see the methods and properties of the control itself.
    Charlotte

  11. #11
    2 Star Lounger
    Join Date
    Apr 2003
    Location
    Vail, Colorado, USA
    Posts
    194
    Thanks
    36
    Thanked 0 Times in 0 Posts

    Re: ActiveX Calendar (2000)

    I did not know that I thought if they were in the drop down box they were available. In my case as Isaid in an earlier post I put a breakpoint in to make sure it was running. after getting your post I went back and put a msgbox in as well to be doublly sure. Any help with why I cannot select the date in the calendar will be greatly appreciated.
    Thanks
    Peter

Posting Permissions

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