PC Review


Reply
Thread Tools Rate Thread

Calendar Compile Error

 
 
Apprentice
Guest
Posts: n/a
 
      3rd Feb 2009
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
--
Your guidance is greatly appreciated!
 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      3rd Feb 2009
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



--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Apprentice" <(E-Mail Removed)> wrote in message
news:8A93B316-787F-49EC-B1E3-(E-Mail Removed)...
>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
> --
> Your guidance is greatly appreciated!



 
Reply With Quote
 
dymondjack
Guest
Posts: n/a
 
      3rd Feb 2009
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


"Apprentice" wrote:

> 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
> --
> Your guidance is greatly appreciated!

 
Reply With Quote
 
Apprentice
Guest
Posts: n/a
 
      3rd Feb 2009
Thanks Doug that was it.... Don't know how I could have missed that at 2am in
the morning.
--
Your guidance did the trick!


"Douglas J. Steele" wrote:

> 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
>
>
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "Apprentice" <(E-Mail Removed)> wrote in message
> news:8A93B316-787F-49EC-B1E3-(E-Mail Removed)...
> >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
> > --
> > Your guidance is greatly appreciated!

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Export report to Excel, Error message "Compile Error: Argument not mc Microsoft Access External Data 0 16th Jul 2009 09:11 PM
Error in Calendar tool - Compile Error Steen Microsoft Excel Programming 2 14th Jan 2008 09:31 PM
excel 2003 - error in starting the program compile error in AutoExecNew Sam Microsoft Excel Misc 3 13th Feb 2006 03:27 PM
VBAProject name compile error, not defined at compile time Matthew Dodds Microsoft Excel Programming 1 13th Dec 2005 07:17 PM
Using Outlook to access and compile information in calendar JEM Microsoft Outlook 0 6th May 2004 10:18 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:58 PM.