
Signature
Dave Hargis, Microsoft Access MVP
Aye, me too MsCal.ocx at first looked like exactly what I needed, and it
worked for about 30 minutes of testing, after which I got a message from
access saying it was corrupt and the dialog box let me "reinstall" the
component. However from that point on, the value of the day clicked on was
not changing the ocxCalendar.value at the top of the code (like it had done
origianlly) After searching the web and this forum I discovered the
hornets-nest that was known as "Microsoft Calendar 11 Active X control" One
of the posts that was telling about the issues mentioned a free calendar
download that was implemented fully as a MSAccess form.
It is this access form popup calendar that I am now using.
Here is a link to the calendar form I am using:
http://www.advancingsoftware.com/FreeDownloads.html
I have made the suggested change to the download modules that allow one
calendar to be called for several date fields. My main form has a global
variable ctlIn that is set when one of the date field's gotFocus or MouseDown
event runs. The Field name is passed through via sControlName.
Set ctlIn = Me.Controls(sControlName)
DoCmd.OpenForm "frmCalendar"
Those statements are in the main form module. I attempted to call the main
forms afterupdate event from the frmCalendar's module but the Me object is
not the correct one at that point.
I also tried setting ctlIn.Dirty = true; thinking that this would make the
event fire after the main form was the current form again, but I was not able
to get the synxax right.
How would I code a reference to the mainform so I could use it's control
values from outside the mainform module? I need to have the groupkey
available to stick in the SQL update's Where clause. I already have the date
value because the frmCalendar's local variable has that for me already. I am
thinking that a new global variable could be set at the same time ctlIn is
being set (or perhaps I just need the correct syntax for refering to
ctlIn.GroupKeyValue. I will also need a correct reference to the sub-form as
a newMe.Control("subform") type that will allow a .requery

Signature
Regards,
John
> I don't use the Microsoft Calendar control because it is an Active X control
> and I avoid using them; however, if the calendar control has an After Update
[quoted text clipped - 43 lines]
> > > > What are the suggested ways to cause the on-change code to execute from a
> > > > form class module that is outside the main form?
Klatuu - 29 Feb 2008 21:18 GMT
Not a global varialbe. They are not as bad as ActiveX controls, but do come
with a set of problems.
If you need to address your main form from the calendar control's module (I
assume it must be an add in if you weren't able to use Me.) you need to
reference the main form as
Forms!NameOfForm!Name Of Control.
You can't run the main form's After Update event from another module,
because it is public; however, you could create a Public Sub in a standard
module and more your After Update code there. Then in the AfterUpate event
call the public sub. Then you could also call it from the calander's module.

Signature
Dave Hargis, Microsoft Access MVP
> Aye, me too MsCal.ocx at first looked like exactly what I needed, and it
> worked for about 30 minutes of testing, after which I got a message from
[quoted text clipped - 82 lines]
> > > > > What are the suggested ways to cause the on-change code to execute from a
> > > > > form class module that is outside the main form?
John Keith - 29 Feb 2008 22:13 GMT
I had to modify the syntax slightly:
Forms("formname").Controls("Groupkey") '<- to populate the SQL Where clause
Forms("formname").Controls("Datefield") '<- to populate the SQL Set clause
Forms("formname").Controls("Subform").Requery '<-to make the newly updated
records show in the sub-form
The frmCalendar routine that changed the ctlIn variable then calls a
standard module that references the form in the above syntax does the trick
Thanks for all the help Dave

Signature
Regards,
John
> Not a global varialbe. They are not as bad as ActiveX controls, but do come
> with a set of problems.
[quoted text clipped - 95 lines]
> > > > > > What are the suggested ways to cause the on-change code to execute from a
> > > > > > form class module that is outside the main form?
Klatuu - 29 Feb 2008 22:16 GMT
Glad you got it working.
You could use:
Forns!FormName!Groupkey, but what you have is fine.

Signature
Dave Hargis, Microsoft Access MVP
> I had to modify the syntax slightly:
> Forms("formname").Controls("Groupkey") '<- to populate the SQL Where clause
[quoted text clipped - 106 lines]
> > > > > > > What are the suggested ways to cause the on-change code to execute from a
> > > > > > > form class module that is outside the main form?