Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / February 2008

Tip: Looking for answers? Try searching our database.

Form event not firing on change

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Keith - 29 Feb 2008 20:03 GMT
I am using a pop-up calendar form that is called from my main form.  

GotFocus and MouseDown events on the main form are calling the popup
calendar.  Once a day has been selected the last thing that happens is the
originating control (the date field on my main form) is being set to the
value of the date selected.  This method does not fire the Change,
BeforeUpdate, nor AfterUpdate events.  

I have looked at RaiseEvent, but the statement that is setting the value of
the originating control is in calendar form module not the main form module.  

I also tried putting the onupdate code in a seperate module that is called
from the calendar form right after the control fields value is set.   The Me.
object was not available (perhaps there is a way to assign the current
database to a variable in that module?)

What are the suggested ways to cause the on-change code to execute from a
form class module that is outside the main form?

Signature

Regards,
John

Klatuu - 29 Feb 2008 20:11 GMT
Those events do not fire if data is entered programmatically.  The only fire
when a user types data directly into them.

Perhaps if you explain what you are trying to do, we can offer a How To for
you.
Signature

Dave Hargis, Microsoft Access MVP

> I am using a pop-up calendar form that is called from my main form.  
>
[quoted text clipped - 14 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 20:27 GMT
The "change" code that needs to run is a SQL update for the table that
updates multiple rows.

My main form handles selecting the group key for the rows. A sub-form shows
the rows that match that group key.  The AfterUpdate event handles the
process perfectly, thanks to Albert's quick reply to my "Write Conflict
Issue" recent post.  I am now attempting to add the popup calendar form to
pick a valid date and this process launches a new form where the mainform:
datefield control is actually updated.  I need to have the Mainform's:
datefield_AfterUpdate event code run when the calendar form's OnClick event
programmatically changes that value.

Hope that makes sense, if not ask again and I will attempt to be more
descriptive.
-
-
Regards,
John

> Those events do not fire if data is entered programmatically.  The only fire
> when a user types data directly into them.
[quoted text clipped - 20 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 20:30 GMT
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
or Lost focus event, you could execute the query from there.
Signature

Dave Hargis, Microsoft Access MVP

> The "change" code that needs to run is a SQL update for the table that
> updates multiple rows.
[quoted text clipped - 39 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 21:11 GMT
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?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.