Month Calendar

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
ByRe[G] or ByRe[F]? If its ByRef, are you using Option Explicit to force
you to DIM all of your variables?
 
Sorry... typo - I meant ByRef. I think Option Explicit is used, I know it is
on some modules but not within the one in question.

Sue


David C. Holley said:
ByRe[G] or ByRe[F]? If its ByRef, are you using Option Explicit to force
you to DIM all of your variables?
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
 
Sue please follow the detailed instructions for how to implement the
MonthCalendar within your own MDB. The instructions are easy to follow and
step by step.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
hughess7 said:
Sorry... typo - I meant ByRef. I think Option Explicit is used, I know it
is
on some modules but not within the one in question.

Sue


David C. Holley said:
ByRe[G] or ByRe[F]? If its ByRef, are you using Option Explicit to force
you to DIM all of your variables?
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
 
I have used it twice so far without any problems, this time round though I
copied and pasted the code to a new field on a different form and it won't
compile. It is within the same db though so not sure how re-reading the
instructions will help? I'll have a look back at your site thanks...


Stephen Lebans said:
Sue please follow the detailed instructions for how to implement the
MonthCalendar within your own MDB. The instructions are easy to follow and
step by step.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
hughess7 said:
Sorry... typo - I meant ByRef. I think Option Explicit is used, I know it
is
on some modules but not within the one in question.

Sue


David C. Holley said:
ByRe[G] or ByRe[F]? If its ByRef, are you using Option Explicit to force
you to DIM all of your variables?

hughess7 wrote:
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
 
Back
Top