Can"t Call Public Function for Pop Up Calendar

Can"t Call Public Function for Pop Up Calendar

am 21.12.2007 10:50:24 von larry.dahlgren

I have downloaded a great pop up calendar (that doesn't use ActiveX
Controls) from http://allenbrowne.com/ser-51.html. Actually it
onvolves downloading a sample database and then following the
instructions:
________________________________________________________
To use the calendar in your database:

1. Import form frmCalendar and module ajbCalendar into your
database.
2. Copy the calendar button from the sample form onto your form.
(There are two styles to choose from.)
3. Set the On Click property of the button to something like this:
=CalendarFor([SaleDate], "Select the sale date")
4. Change SaleDate to the name of your date text box. The quoted
text is optional, for the title bar of the calendar.
________________________________________________________

After doing so, I get the following message when clicking on the
button:

"The Expression OnClick you entered as the Event Property setting
produced the following error: Procedure declaration does not match
description of event or procedure having the same name.

The code is in a Public Module. I have tested to ensure that the
function is not called at all before failing (put a MsgBox as the
first line of code in the module to see if it fails after calling it)

Any ideas or assistance would be appreciated.

Re: Can"t Call Public Function for Pop Up Calendar

am 21.12.2007 14:52:13 von Tom van Stiphout

On Fri, 21 Dec 2007 01:50:24 -0800 (PST), larry.dahlgren@telus.com
wrote:

The sample code works. Yours does not. Carefully inspect both
side-by-side and you should be able to figure out where yours goes
wrong.
Or post your code here (what you put in the OnClick property of the
button).

-Tom.


>I have downloaded a great pop up calendar (that doesn't use ActiveX
>Controls) from http://allenbrowne.com/ser-51.html. Actually it
>onvolves downloading a sample database and then following the
>instructions:
>________________________________________________________
>To use the calendar in your database:
>
> 1. Import form frmCalendar and module ajbCalendar into your
>database.
> 2. Copy the calendar button from the sample form onto your form.
>(There are two styles to choose from.)
> 3. Set the On Click property of the button to something like this:
> =CalendarFor([SaleDate], "Select the sale date")
> 4. Change SaleDate to the name of your date text box. The quoted
>text is optional, for the title bar of the calendar.
>________________________________________________________
>
>After doing so, I get the following message when clicking on the
>button:
>
>"The Expression OnClick you entered as the Event Property setting
>produced the following error: Procedure declaration does not match
>description of event or procedure having the same name.
>
>The code is in a Public Module. I have tested to ensure that the
>function is not called at all before failing (put a MsgBox as the
>first line of code in the module to see if it fails after calling it)
>
>Any ideas or assistance would be appreciated.

Re: Can"t Call Public Function for Pop Up Calendar

am 21.12.2007 19:00:17 von larry.dahlgren

On Dec 21, 5:52 am, Tom van Stiphout wrote:
> On Fri, 21 Dec 2007 01:50:24 -0800 (PST), larry.dahlg...@telus.com
> wrote:
>
> The sample code works. Yours does not. Carefully inspect both
> side-by-side and you should be able to figure out where yours goes
> wrong.
> Or post your code here (what you put in the OnClick property of the
> button).

The downloaded copy of the database works great. It is when I import
the modules and copy the buttons into my test database that it stops
working.

Here is what I have entered into the OnClick property (I cut and paste
from Allen Browne's button property then changed the control name to
my date text field):

On Click: =CalendarFor([txtSubmitDate],"Set the start date")

This is the code it calls, which is in a module called "ajbCalendar"

Option Compare Database
Option Explicit

'Calendar form variable:
Public gtxtCalTarget As TextBox 'Text box to return the date from the
calendar to.
____________________________________________________________ _______
Public Function CalendarFor(txt As TextBox, Optional strTitle As
String)
On Error GoTo Err_Handler
'Purpose: Open the calendar form, identifying the text box to
return the date to.
'Arguments: txt = the text box to return the date to.
' strTitle = the caption for the calendar form (passed
in OpenArgs).

Set gtxtCalTarget = txt
DoCmd.OpenForm "frmCalendar", windowmode:=acDialog,
OpenArgs:=strTitle

Exit_Handler:
Exit Function

Err_Handler:
MsgBox "Error " & Err.Number & " - " & Err.Description,
vbExclamation, "CalendarFor()"
Resume Exit_Handler
End Function
____________________________________________________________ ________

I know there is nothing wrong with the code - and am pretty sure about
the On Click property. I'm wondering if there is something in the
environmental settings of my db. I have tried changing security
levels which is one of the ideas under the help area of the error
message.

Any thoughts?

Larry Dahlgren

Re: Can"t Call Public Function for Pop Up Calendar

am 22.12.2007 00:21:43 von larry.dahlgren

Issue Resolved.

Allen Brown - you built a great calendar.

Re: Can"t Call Public Function for Pop Up Calendar

am 22.12.2007 05:09:59 von Tom van Stiphout

On Fri, 21 Dec 2007 15:21:43 -0800 (PST), Larry Dahlgren
wrote:

What was wrong?
-Tom.


>Issue Resolved.
>
>Allen Brown - you built a great calendar.