Calendar Control Re-Use

T

Terry Roberts

I have a multi-tabbed Access form which uses the Calendar
Control to allow users to select dates. On my scheduling
tab, I have over twenty date fields, each with their own
calendar control. Is there some way I can use just one
control? What I would like to do is have a toggle next to
each date text box, and when the toggle was activated, the
calendar control becomes visible. After the user picks a
date, the selected date would be assigned back to the date
textbox associated with the toggle that activated the
calendar (and the calendar's visibility property would
return to false). This would not affect the values of any
of the other date textboxes. Can this be done?

TIA,

Terry Roberts
 
P

PC Datasheet

Terry,

Here's a much simpler way to do what you want to do:

Put the following function in a standard module:
Function EnterDate()
DoCmd.OpenForm "NameOfYourCalendarForm", , , , , acDialog
Forms!NameOfYourMultiTabbedForm.ActiveControl = _
Forms!NameOfYourCalendarForm!NameOfYourCalendarControl.Value
DoCmd.Close acForm, "NameOfYourCalendarForm"
End Function

Note - the 4th and 5th lines are 1 line of code!

Select all your date fields at once and enter this expression in the On Got
Focus event:
=EnterDate()

Note - you won't get the typical form code module; enter the expression right on
the event line.

Now, when you enter any of the date fields, the calendar will pop-up and when
the user selects a date, the calendar disappears and the date appears in the
date field that was entered.
 
T

Terry Roberts

Thanks for the tip, but I'm still having problems making
it work. Here's the code I'm using for the function:
Public Function EnterDate()
'Kindly provided by PC Datasheet.
DoCmd.OpenForm "frmCalendar", , , , , acDialog
Forms!frmOpportunities.ActiveControl = Forms!
frmCalendar!actxCalendar.Value
DoCmd.Close acForm, "frmCalendar"
End Function

The form with the calendar appears, but nothing happens
when you select a date (by clicking on it). Any thoughts
on how to automatically feed the date back & close the
form?

Terry
 
P

PC Datasheet

Terry,

It's my fault; I forgot to give you some other code - Sorry!

Open your calendar form to the code module and type in the following code:
Private Sub actxCalendar_AfterUpDate()
Me.Visible = False
End Sub

You need to type it all in because the calendar properties does not expose the
AfterUpdate event.

Steve
PC Datasheet
 
M

MikeB

Terry,
On my site, you can download an Acess2K database that demonstrates the reuse of a form containing a
single calendar control that is callable via the methods demonstrated (onClick, onDblClick, Command
Button). There is ample sample code with commenting to help you infuse it into your own application.
The Calendar is callable in Datasheet View as well.

direct link to the zipfile http://www.byerley.net/AccessCalDemo.zip

or to http://www.byerley.net/BdcDownSup.htm and scroll down to the AcessCalDemo.Zip link.

HTH
 
T

Terry Roberts

Steve,

That did the trick! Your code was exactly what I was
looking for. Thanks for the assist!

Terry
 
T

Terry Roberts

Mike,

Thanks for the tip - I had already incorporated Steve's
suggestion, and it's worked for my application. I'll
definitely check out your method as well.

Best regards,

Terry Roberts
-----Original Message-----
Terry,
On my site, you can download an Acess2K database that
demonstrates the reuse of a form containing a
single calendar control that is callable via the methods
demonstrated (onClick, onDblClick, Command
Button). There is ample sample code with commenting to
help you infuse it into your own application.
The Calendar is callable in Datasheet View as well.

direct link to the zipfile http://www.byerley.net/AccessCalDemo.zip

or to http://www.byerley.net/BdcDownSup.htm and scroll
down to the AcessCalDemo.Zip link.
 
G

Guest

Steve,

The calendar form is working great on my Access 2002
platform, but users who try to open it with Access 2000
get an error about a missing DLL. This was not a problem
in the previous version, where I had a separate calendar
control tied to each date field.
I noticed that the version of the calendar control is 10.0
in A2K2 - could that be part of the problem?

Terry
 
T

Terry Roberts

Steve,

Please disregard - I discovered the source of the problem.
My daughter had installed AOL 9.0 on my development
station, and it included an AOLCalSvr type library. When I
compiled the code, it worked on my machine because it was
present. Other users (who did not have AOL 9.0 installed)
were getting the error about the missing DLL.

Terry
 

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