Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 09-07-2010, 02:55 PM   #1
Rx_
Nothing In Moderation
 
Rx_'s Avatar
 
Join Date: Oct 2009
Location: Denver, Colorado
Posts: 2,803
Thanks: 636
Thanked 337 Times in 307 Posts
Rx_ has a spectacular aura about Rx_ has a spectacular aura about Rx_ has a spectacular aura about
Question Return to Main form from second form - Event wont fire

On a Master Form with a listbox (lst_id_wells) - if the value of a well is passed into a custom function ROW_Required_For_Well - it turns a colored box on or off. This just gives a visable indicator to the user as they scroll down a list box - if that Well has a ROW or not.

This form stays open, another form opens. It displays a list of ROW. If a user chooses a different ROW, it updates that form's ROW and it updates the Master Form's list box ROW (the list_id_Wells value is correctly highlighted).

Problem - The code below won't fire in any event that on the Master Form. So, when closing the secondary form, the Master Form list box has a Well selected that won't hight-light the ROW.
Tried the Master Forms's Got Focus, Resize, and so on.

The secondary form changes the Master Form lst_Id_Wells value with the code:
Forms![home_2]![lst_id_wells] = Me.ID_Wells
The code above highlights the correct item in the listbox,
But, changing the value from another form does not trigger the AfterUpdate (or any other event) to run the function.

Code:
Private Sub lst_id_wells_AfterUpdate()
10    On Error Resume Next
20    If Not IsNull(Me!lst_id_wells) Then
30            If ROW_Required_For_Well(Me!lst_id_wells) Then
40                Me.BoxRowIndicator.Visible = True
50            Else
60                Me.BoxRowIndicator.Visible = False
70            End If
80    End If

__________________
Were you lucky enough to get an answer? Please mark your question as [SOLVED] The original poster can go to Thread Tools to mark it as Solved.

Quotation Thomas Jefferson: "Peace is that brief glorious moment in history when everybody stands around reloading."

There are 2 Kinds of Countries on this Planet
1. Those that use the Metric System
2. Those that had a man walk on the moon

Denver, Colorado - The "Mile High City" - non-metric!

Last edited by Rx_; 09-07-2010 at 02:58 PM. Reason: spelling
Rx_ is offline   Reply With Quote
Old 09-07-2010, 03:17 PM   #2
RuralGuy
AWF VIP
 
RuralGuy's Avatar
 
Join Date: Jul 2005
Location: @ 8300' in the Colorado Rockies
Posts: 13,821
Thanks: 7
Thanked 311 Times in 301 Posts
RuralGuy is just really nice RuralGuy is just really nice RuralGuy is just really nice RuralGuy is just really nice RuralGuy is just really nice
Re: Return to Main form from second form - Event wont fire

Events do not fire unless the USER makes the change. Programatically changing something does not fire any events. If you want them to execute then you need to call them in code.
__________________
(RG for short) aka Allan Bunch Previous MS Access MVP acXP, ac07, ac10, ac13 - WinXP Pro, Win7 Pro, Win10 Pro
Please post back to this Forum so all may benefit.
Teaching is not filling a bucket but lighting a fire.
RuralGuy is offline   Reply With Quote
Old 09-08-2010, 06:28 AM   #3
Rx_
Nothing In Moderation
 
Rx_'s Avatar
 
Join Date: Oct 2009
Location: Denver, Colorado
Posts: 2,803
Thanks: 636
Thanked 337 Times in 307 Posts
Rx_ has a spectacular aura about Rx_ has a spectacular aura about Rx_ has a spectacular aura about
Thumbs up Re: Return to Main form from second form - Event wont fire

Thanks. Yes, that is the exact problem.
The solution is to put this code in the second form to call the even in the Master form:

Call Form_Home_2.lst_id_wells_AfterUpdate
i.e. Form_Name.ProcedureName
Also:
In the list object, the event with the function that changes the boxes in the Master form must be changed from Private to Public

Public Sub lst_id_wells_AfterUpdate()
' the code that calls functions to update the boxes with user interaction was here.

When the second form updates the primary key (i.e. list box) on the Master form, it did not call the event. Because events are fired by users actions.
By adding the code above (and makeing the event on the Master form) public, the VBA code calls the event.

This is probably restating the obvious. I posted this at the end of a 10 hour day, the solution seemed so simple this morning.

__________________
Were you lucky enough to get an answer? Please mark your question as [SOLVED] The original poster can go to Thread Tools to mark it as Solved.

Quotation Thomas Jefferson: "Peace is that brief glorious moment in history when everybody stands around reloading."

There are 2 Kinds of Countries on this Planet
1. Those that use the Metric System
2. Those that had a man walk on the moon

Denver, Colorado - The "Mile High City" - non-metric!
Rx_ is offline   Reply With Quote
Reply

Tags
event , form , gets focus

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Query will not get values from form Cpowell Queries 6 05-21-2009 04:11 AM
Protecting a WORD form PaulO Word 1 04-30-2009 06:50 AM
To fire Double Click event of Subform from Main Form Savita General 2 09-06-2007 05:29 AM
Creating main form with two subforms HELP duckster Forms 8 09-20-2004 12:48 PM
Fill a new form with info from a main form Matt Rayne Forms 5 01-26-2003 12:47 PM




All times are GMT -8. The time now is 01:55 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World