D
DS
I have this Calendar that I set-up. It works except I can't get the
Month and Year to appear in the Titlebar. It says sub or function not
defined.
Thanks
DS
Option Compare Database
Function SetCalendar(ByVal Flag As Integer) As Integer
Dim MyForm As Form, MyControl As Control
Dim MaxDays As Integer, Offset As Integer, X As Integer
Static M As Double
SetCalendar = True
Set MyForm = Forms![Calendar]
Select Case Flag
Case -2, 2
M = DateAdd("yyyy", Flag - (Flag * 0.5), M)
Case -1, 1
M = DateAdd("m", Flag, M)
Case 0
M = DateValue(DatePart("m", Date$) & "/1/" & DatePart("yyyy",
Date$))
End Select
MaxDays = Val(Mid$("312831303130313130313031", DatePart("m", M) * 2 - 1, 2))
If DatePart("m", M) = 2 Then
If DatePart("yyyy", M) Mod 4 = 0 And DatePart("yyyy", M) Mod 400 <>
0 Then
MaxDays = 29
End If
End If
Offset = DatePart("w", M)
For X = 1 To 42
Set MyControl = MyForm("Day" & Str$(X))
If X < Offset Or X > Offset + MaxDays - 1 Then
MyControl = ""
Else
MyControl = X - Offset + 1
End If
Next X
X = SetTitleBar("Calendar", Format$(M, "mmm yyyy"))
End Function
Month and Year to appear in the Titlebar. It says sub or function not
defined.
Thanks
DS
Option Compare Database
Function SetCalendar(ByVal Flag As Integer) As Integer
Dim MyForm As Form, MyControl As Control
Dim MaxDays As Integer, Offset As Integer, X As Integer
Static M As Double
SetCalendar = True
Set MyForm = Forms![Calendar]
Select Case Flag
Case -2, 2
M = DateAdd("yyyy", Flag - (Flag * 0.5), M)
Case -1, 1
M = DateAdd("m", Flag, M)
Case 0
M = DateValue(DatePart("m", Date$) & "/1/" & DatePart("yyyy",
Date$))
End Select
MaxDays = Val(Mid$("312831303130313130313031", DatePart("m", M) * 2 - 1, 2))
If DatePart("m", M) = 2 Then
If DatePart("yyyy", M) Mod 4 = 0 And DatePart("yyyy", M) Mod 400 <>
0 Then
MaxDays = 29
End If
End If
Offset = DatePart("w", M)
For X = 1 To 42
Set MyControl = MyForm("Day" & Str$(X))
If X < Offset Or X > Offset + MaxDays - 1 Then
MyControl = ""
Else
MyControl = X - Offset + 1
End If
Next X
X = SetTitleBar("Calendar", Format$(M, "mmm yyyy"))
End Function