Calendar Compile Error

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
 
D

Douglas J. Steele

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
 
D

dymondjack

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
 
A

Apprentice

Thanks Doug that was it.... Don't know how I could have missed that at 2am in
the morning.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top