perhol
01-20-2008, 11:39 AM
I am using lucas' Userform Calendar Control, changed by xld to start the week on mondays, and it is nearly perfect.
When the control is visible, holding the mouse over a control, a tip (like a tooltip) pops up. VBA calls the tip ControlTipText
The tip shows the date in the form "m-d-yy", but, living in Denmark, i would like the tip to show in the form "d-m-yy" or not show at all.
I can change it to show in the form i want, but that creates another problem.:banghead:
By pressing the control, the date is inserted in the selected cell. If i don't change the ControlTipText, the chosen date is inserted correct in the form "dd. mmmm", ie. 10. marts (danish for march).
If i change the ControlTipText to "d-m-yy", the wrong date is inserted in the selected cell. If i have chosen 10. march, 3. october is inserted.
Can anyone change the ControlTipText to show in the form "d-m-yy" or not show at all.
Here is the vba that builds the calendar:
Private Sub Build_Calendar()
'Rutinen der rent faktisk opbygger kalenderen hver gang
If CreateCal = True Then
CalendarFrm.Caption = " " & CB_Mth.Value & " " & CB_Yr.Value
'S?tter focus p? knappen for dagsdato
CommandButton1.SetFocus
For i = 1 To 42
If i < Weekday((CB_Mth.Value) & "/1/" & (CB_Yr.Value)) Then
Controls("D" & (i)).Caption = Format(DateAdd("d", (i - Weekday((CB_Mth.Value) & "/1/" & (CB_Yr.Value), 2)), _
((CB_Mth.Value) & "/1/" & (CB_Yr.Value))), "d")
Controls("D" & (i)).ControlTipText = Format(DateAdd("d", (i - Weekday((CB_Mth.Value) & "/1/" & (CB_Yr.Value), 2)), _
((CB_Mth.Value) & "/1/" & (CB_Yr.Value))), "m/d/yy")
ElseIf i >= Weekday((CB_Mth.Value) & "/1/" & (CB_Yr.Value)) Then
Controls("D" & (i)).Caption = Format(DateAdd("d", (i - Weekday((CB_Mth.Value) _
& "/1/" & (CB_Yr.Value), 2)), ((CB_Mth.Value) & "/1/" & (CB_Yr.Value))), "d")
Controls("D" & (i)).ControlTipText = Format(DateAdd("d", (i - Weekday((CB_Mth.Value) & "/1/" & (CB_Yr.Value), 2)), _
((CB_Mth.Value) & "/1/" & (CB_Yr.Value))), "m/d/yy")
End If
If Format(DateAdd("d", (i - Weekday((CB_Mth.Value) & "/1/" & (CB_Yr.Value), 2)), _
((CB_Mth.Value) & "/1/" & (CB_Yr.Value))), "mmmm") = ((CB_Mth.Value)) Then
If Controls("D" & (i)).BackColor <> &H80000016 Then Controls("D" & (i)).BackColor = &H80000018
Controls("D" & (i)).Font.Bold = True
If Controls("D" & (i)).BackColor = &H80000016 Then Controls("D" & (i)).BackColor = &H80000003
Controls("D" & (i)).Font.Bold = True
If Format(DateAdd("d", (i - Weekday((CB_Mth.Value) & "/1/" & (CB_Yr.Value), 2)), _
((CB_Mth.Value) & "/1/" & (CB_Yr.Value))), "m/d/yy") = Format(ThisDay, "m/d/yy") Then Controls("D" & (i)).SetFocus
Else
If Controls("D" & (i)).BackColor <> &H80000016 Then Controls("D" & (i)).BackColor = &H8000000F
Controls("D" & (i)).Font.Bold = False
End If
Next
End If
End Sub
When the control is visible, holding the mouse over a control, a tip (like a tooltip) pops up. VBA calls the tip ControlTipText
The tip shows the date in the form "m-d-yy", but, living in Denmark, i would like the tip to show in the form "d-m-yy" or not show at all.
I can change it to show in the form i want, but that creates another problem.:banghead:
By pressing the control, the date is inserted in the selected cell. If i don't change the ControlTipText, the chosen date is inserted correct in the form "dd. mmmm", ie. 10. marts (danish for march).
If i change the ControlTipText to "d-m-yy", the wrong date is inserted in the selected cell. If i have chosen 10. march, 3. october is inserted.
Can anyone change the ControlTipText to show in the form "d-m-yy" or not show at all.
Here is the vba that builds the calendar:
Private Sub Build_Calendar()
'Rutinen der rent faktisk opbygger kalenderen hver gang
If CreateCal = True Then
CalendarFrm.Caption = " " & CB_Mth.Value & " " & CB_Yr.Value
'S?tter focus p? knappen for dagsdato
CommandButton1.SetFocus
For i = 1 To 42
If i < Weekday((CB_Mth.Value) & "/1/" & (CB_Yr.Value)) Then
Controls("D" & (i)).Caption = Format(DateAdd("d", (i - Weekday((CB_Mth.Value) & "/1/" & (CB_Yr.Value), 2)), _
((CB_Mth.Value) & "/1/" & (CB_Yr.Value))), "d")
Controls("D" & (i)).ControlTipText = Format(DateAdd("d", (i - Weekday((CB_Mth.Value) & "/1/" & (CB_Yr.Value), 2)), _
((CB_Mth.Value) & "/1/" & (CB_Yr.Value))), "m/d/yy")
ElseIf i >= Weekday((CB_Mth.Value) & "/1/" & (CB_Yr.Value)) Then
Controls("D" & (i)).Caption = Format(DateAdd("d", (i - Weekday((CB_Mth.Value) _
& "/1/" & (CB_Yr.Value), 2)), ((CB_Mth.Value) & "/1/" & (CB_Yr.Value))), "d")
Controls("D" & (i)).ControlTipText = Format(DateAdd("d", (i - Weekday((CB_Mth.Value) & "/1/" & (CB_Yr.Value), 2)), _
((CB_Mth.Value) & "/1/" & (CB_Yr.Value))), "m/d/yy")
End If
If Format(DateAdd("d", (i - Weekday((CB_Mth.Value) & "/1/" & (CB_Yr.Value), 2)), _
((CB_Mth.Value) & "/1/" & (CB_Yr.Value))), "mmmm") = ((CB_Mth.Value)) Then
If Controls("D" & (i)).BackColor <> &H80000016 Then Controls("D" & (i)).BackColor = &H80000018
Controls("D" & (i)).Font.Bold = True
If Controls("D" & (i)).BackColor = &H80000016 Then Controls("D" & (i)).BackColor = &H80000003
Controls("D" & (i)).Font.Bold = True
If Format(DateAdd("d", (i - Weekday((CB_Mth.Value) & "/1/" & (CB_Yr.Value), 2)), _
((CB_Mth.Value) & "/1/" & (CB_Yr.Value))), "m/d/yy") = Format(ThisDay, "m/d/yy") Then Controls("D" & (i)).SetFocus
Else
If Controls("D" & (i)).BackColor <> &H80000016 Then Controls("D" & (i)).BackColor = &H8000000F
Controls("D" & (i)).Font.Bold = False
End If
Next
End If
End Sub