Lebans Calendar Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I recently downloaded Stephans calendar control, and basically it works
great. I have read on his site that the latest version had support for the
user using the Enter key to select a date rather than just rely on a mouse
click...

A couple of questions: 1) how do I tell if the code modules I downloaded are
the correct version? 2) Do I have to do anything in the code calling the
control to enable the Enter key behavior?

Appreciate any pointers that can be thrown my way.

Ed
 
Hi Ed,
Comments below...
I recently downloaded Stephen's calendar control, and basically it works great.

You have chosen wisely.
:-)
I have read on his site that the latest version had support for the
user using the Enter key to select a date rather than just rely on a mouse click...

Yes, that is correct.
A couple of questions:
1) how do I tell if the code modules I downloaded are the correct version?

That's a little difficult to tell. I happen to have some older versions of Sensei's calendar and the
Enter key does not work to select a date. However, it would be a challenge for sure to see where the
differences are in his code. I'm not sure an exact version number is in the comments area each time.
If the Enter key does not select a date with the version you have, then you would most likely not
have the latest modules.

The best thing to do is to just download the latest version of the modules into your database.
Stephen will periodically fix minor bugs and release an updated version. So to have the 'cleanest'
code I would do this:
- Make a backup of your database
- Delete the five modules in your database
- Compact the database
- Download the latest version of the modules and unzip the file
- Import the five modules into your database
- Check References by Tools | References
- Compile the database
- Compact the database

There was a significant change in the calling code after version 9.2. If you have a version before
9.2 you will have to make changes to the calling code. Just follow the step-by-step instructions.
2) Do I have to do anything in the code calling the
control to enable the Enter key behavior?

I do not believe so. The Enter key will work by default.
 
Thanks Jeff...

I pretty much determined that I have the latest version as I looked at the
Zip. The version I got *says* it's "203" which I take to be version 2.03

I didn't follow your suggestions to the letter setting things up-noteably
the comapctions steps. So I tried this time, deleting the modules,
compacting, and re-importing them. No go... :-(

Re-downloaded (seems to be the same file)...followed the steps...no
reference problems...still no enter key...

Here's a sample of the code I'm using to call the MC:

************************************
Private Sub RecUHC_DblClick(Cancel As Integer)

Set mc = New clsMonthCal
mc.hWndForm = Me.hWnd

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

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

blRet = ShowMonthCalendar(mc, dtStart, dtEnd)

If blRet = True Then
Me.RecUHC = dtStart
Call RecUHC_AfterUpdate
End If

SendKeys "{TAB}"

End Sub
************************************

Pretty much a lift from your example now on Stephan's site.

Appreciate your reply and help. I suppose I could live with the situation,
but I really don't like having operations in my apps that can only de done
via a mouse...thanks!
 
Hi Ed, comments below....
I pretty much determined that I have the latest version as I looked at the
Zip. The version I got *says* it's "203" which I take to be version 2.03

Ok.
What operating system and Access version are you using by the way?
I didn't follow your suggestions to the letter setting things up-noteably
the comapctions steps. So I tried this time, deleting the modules,
compacting, and re-importing them. No go... :-(

You did not mention this, but did you compile the code?
This is MOST important!
Re-downloaded (seems to be the same file)...followed the steps...no
reference problems...still no enter key...

Did you compile?
Here's a sample of the code I'm using to call the MC:

************************************
Private Sub RecUHC_DblClick(Cancel As Integer)

Set mc = New clsMonthCal
mc.hWndForm = Me.hWnd

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

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

blRet = ShowMonthCalendar(mc, dtStart, dtEnd)

If blRet = True Then
Me.RecUHC = dtStart
Call RecUHC_AfterUpdate
End If

SendKeys "{TAB}"

End Sub
************************************

Pretty much a lift from your example now on Stephan's site

I'm afraid that is NOT a lift from the instructions on the web site!

These lines....:
Set mc = New clsMonthCal
mc.hWndForm = Me.hWnd

....need to be in the Form's Load event, not the procedure events.

Did you also include this code in the Declarations area of the form module (up near the top)?:

Private mc As clsMonthCal

Did you also include the Unload code?

Using one form with nothing but a text box on it with the name you provided here is ALL the code you
will need behind the form to make Stephen's calendar work. This is the bare minimum of code and this
should all be in your form's code module:

' Start of form code
Option Compare Database
Option Explicit

' This part is in the Declarations area of the form module
Private mc As clsMonthCal

Private Sub Form_Load()

Set mc = New clsMonthCal
mc.hWndForm = Me.hWnd

End Sub

Private Sub Form_Unload(Cancel As Integer)

If Not mc Is Nothing Then
If mc.IsCalendar Then
Cancel = 1
Exit Sub
End If
Set mc = Nothing
End If

End Sub

Private Sub RecUHC_AfterUpdate()
' Whatever code you have going on here
End Sub

Private Sub RecUHC_DblClick(Cancel As Integer)

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

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

blRet = ShowMonthCalendar(mc, dtStart, dtEnd)

If blRet = True Then
Me.RecUHC = dtStart
Call RecUHC_AfterUpdate
End If

SendKeys "{TAB}"

End Sub
' End of form code

The calendar pops up and the Enter key or mouse can select a date every time in my tests.
Appreciate your reply and help. I suppose I could live with the situation,
but I really don't like having operations in my apps that can only de done
via a mouse...thanks!

We'll get it working.
Try the new code provided and then test.
If still unsuccessful please provide OS and Access version information and I'm sure Stephen will
jump in then.
 
Well, I did compile things...

Still not sure about the version. The mdb I downloaded *says* 203, but even
the example forms in it do not have the enter key select behaviour. Hmmm.

From what I read, now that the calendar is modal, do you need the
form_unload code? I'll try it (later-not feeling well right now and just
waiting for folks to get back from lunch so I can update teh latest MDE for
them to test) and see...

As for versions: A2K on Win 2K Pro. I think my references are OK...nothing
said missing.

Appreciate the help!
 
Hi Ed,

Hummm...if the example forms in Stephen's download file do not allow the Enter key to select a date
then something is amiss for sure. I am unable to test with the same Access/OS version you have right
now, but the Enter key works with Access 2K/NT 4.0.

This is most peculiar. Perhaps Stephen will jump in now and help with the problem. Keep checking
back to see if he responds. If he does not respond in a day or so I may ping him for you.
 
OK, Jeff, looking throught he code I have discovered:

1) I have the correct version.
2) It's working fine.

I found this line of code in the modCalendar code:

**********
' June 2 - 2004 - adding support for ENTER key to select currently
highlighted date.
Case MCN_SELCHANGE
**********

Thought..."hmmmmm...." and tried to change the date in the calendar and
*viola* the enter key works.

So basically I want to change the behavior to allow this if the enter key is
used on the default date that the calendar opens up to...

Any hints before I start messing with the code and break things? ;-)
 
OK, found a solution, albeit it seems "dirty"... ;-)

in modCalendar, right after the two lines that show the calendar's parent
window then the calendar window itself, and right before the message loop is
enteres, I put the following:

SendKeys "{UP}"
SendKeys "{DOWN}"

Baically "tricking" the month calendar to think that the selected value has
been changed, and enabling the most recent code added to handle the
MCN_SELCHANGE message in main message loop (WIndowProc) to fire...

Like I said, it's a little cheesy, but it works...
 
I would not reccomend that solution Ed. It will break at some point.

I had to send my main development machine(again) back to the shop to get
a new processor. Send me an Email this weekend and I will look into the
source code and show you what to change to have the MonthCalendar
respond as you require.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Back
Top