G
Guest
Hi, I am using Stephen Lebans Month Calendar. I have it working on one form
but when I tried to copy to another form it fails on trying to compile the
code. It states compile error ByReg argument type mismatch and highlights the
mc part of:
blRet = ShowMonthCalendar(mc, dtStart, dtEnd)
It is a short date field and is set up the same as the other date field on a
different form which works ok? Can anyone shed any light on this please?
Also, I have modified it so a message is displayed if the user does not
select a monday and the date field is not returned. Is there a way to stop
the user being able to select any day other than a Monday in the first place?
Thanks
Sue
Complete code below:
Private Sub StartDate_DblClick(Cancel As Integer)
Dim blRet As Boolean
Dim dtStart As Date, dtEnd As Date
Dim Msg, Style, Title, MyString, Response
dtStart = Nz(Me.StartDate.Value, 0)
dtEnd = 0
blRet = ShowMonthCalendar(mc, dtStart, dtEnd)
If blRet = True Then
If Weekday(dtStart) <> vbMonday Then
Msg = "Start Date must be a Monday"
MsgBox Msg, vbCritical, "Please reselect a Monday date"
Else
Me.StartDate = dtStart
End If
End If
but when I tried to copy to another form it fails on trying to compile the
code. It states compile error ByReg argument type mismatch and highlights the
mc part of:
blRet = ShowMonthCalendar(mc, dtStart, dtEnd)
It is a short date field and is set up the same as the other date field on a
different form which works ok? Can anyone shed any light on this please?
Also, I have modified it so a message is displayed if the user does not
select a monday and the date field is not returned. Is there a way to stop
the user being able to select any day other than a Monday in the first place?
Thanks
Sue
Complete code below:
Private Sub StartDate_DblClick(Cancel As Integer)
Dim blRet As Boolean
Dim dtStart As Date, dtEnd As Date
Dim Msg, Style, Title, MyString, Response
dtStart = Nz(Me.StartDate.Value, 0)
dtEnd = 0
blRet = ShowMonthCalendar(mc, dtStart, dtEnd)
If blRet = True Then
If Weekday(dtStart) <> vbMonday Then
Msg = "Start Date must be a Monday"
MsgBox Msg, vbCritical, "Please reselect a Monday date"
Else
Me.StartDate = dtStart
End If
End If