Calendar Compile Error

  • Thread starter Thread starter Apprentice
  • Start date Start date
A

Apprentice

I downloaded and imported the modules for the MonthCalendar from
http://www.lebans.com/monthcalendar.htm

I followed the instructions exactly but am getting an error when I try to
complie the inserted code. It hangs on the (mc, dtStart, dtEnd) and says
that "mc," is a variable not defined.

Here are the two lines of code in the form:

Private Sub Form_Load()

' Create an instance of our Class
Set mc = New clsMonthCal
' Set the hWndForm Property
mc.hWndForm = Me.hWnd

End Sub

.............................................................................

Private Sub AssignmentDate_DblClick(Cancel As Integer)

' Retrieve the currently selected date(s).
' Call our Function to display the Calendar
' Init the Calendar to select the date
' contained in this control.

Dim blRet As Boolean
Dim dtStart As Date, dtEnd As Date

dtStart = Nz(Me.AssignmentDate.Value, 0)
dtEnd = 0

blRet = ShowMonthCalendar(mc, dtStart, dtEnd)
If blRet = True Then
Me.AssignmentDate.Value = dtStart
Else
MsgBox "Hey - Did you forget to select a date?"
End If

End Sub
 
It appears that you may have missed step 4:

Now in your database open any form in design view that you wish to show the
calendar. Go to the code window behind the form. In the Declarations area
(very top) you need to add this code. So the very first few lines of your
code window will look like this:

Option Compare Database
Option Explicit


' This declares the MonthCalendar Class
Private mc As clsMonthCal
 
Did you include the declaration in your form's module?

' This declares the MonthCalendar Class
Private mc As clsMonthCal


This needs to be after the Option statements at the top of the module, but
before any procedures, and needs to be included with every form module you
use the calendar in.

--
Jack Leach
www.tristatemachine.com

- "First, get your information. Then, you can distort it at your leisure."
- Mark Twain
 
Thanks Doug that was it.... Don't know how I could have missed that at 2am in
the morning.
 
Back
Top