Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calendar control not opening to correct value 2

Status
Not open for further replies.

THWatson

Technical User
Apr 25, 2000
2,601
CA
Using Access 2003

On a form there is a Calendar control, ocxCal

Here is code behind the Forms OnOpen event
Code:
Private Sub Form_Open(Cancel As Integer)
DoCmd.Maximize
Me.fraGuests = Null
Me.txtMeetingDate = Null

End Sub

This causes the calendar to display a value of November 8, 2008 when the form opens.

However if I comment out the DoCmd.Maximize line it opens properly to display today's date, in this case January 26, 2009.

The only other code that I can think of that might interfere is the code on the form's OnLoad event:
Code:
Private Sub Form_Load()
   On Error GoTo Form_Load_Error

Me!ocxCal.Value = Date

   On Error GoTo 0
   Exit Sub

Form_Load_Error:

    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Form_Load of VBA Document Form_frmAttendance"
End Sub

Any ideas as to what causes this?

Tom

 
Have you tried programmatically setting the .Month property to the datepart "M" of the Date() function?

"Don't be irreplaceable. If you can't be replaced, you can't be promoted."
 
How are ya THWatson . . .

If the control happens to be [blue]Microsoft Calendar Control X.X[/blue], then [blue]delete and reinstantiate the control[/blue]. The control automatically defaults to the current date on open.

Also remout or remove the line that sets the date to avoid any interaction.

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
TheAceman1

Yep, this is a Calendar Control 11.0. In Properties it says MSCAL.Calendar.7

I deleted it and reapplied it.

And I commented out the Me!ocxCal.Value = Date line in the form's OnLoad event.

Either way gets the same result - opening with the date in November of 2008 highlighted.

And it's only with the Me!ocxCal.Value = Date included in the OnLoad event that the control opens properly to today's date. I had trouble with this a month or more ago until I put in that line.

Anyway, if things work properly by taking the DoCmd.Maximize out of the form's OnOpen event, that seems to be the simplest solution...and one I can easily live with.

Unless there's a better Calendar control that could be recommended.

Tom
 
TheAceMan1

Thanks. I like the look of the The Accessory Calendar Control Mimic

I'm going to try it out.

Tom
 
TheAceman1
I thought you might be interested in knowing that following a fling in the far country where I wasted my heritage on the Microsoft ActiveX calendar control and a couple of other harlot calendars, I cam back to the Accessory Calendar Control Mimic.

The big deal with the Microsoft calendar control was that it wanted to display different date sequences on different computers - e.g. Sat-Fri rather than Sun-Sat, etc. - and stubbornly refused to yield.

Thanks a lot for suggesting the Mimic one as a possibility.

Tom
 
Roger That THWatson! [thumbsup2]

Definite info for my library. Hopefully yours too!

You take care ... [blue]Ya Hear! . . .[/blue]



See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top