Is there a way to Trigger a Macro in another Subform from a Different Subform? (1 Viewer)

rcb

New member
Local time
Today, 06:57
Joined
Jul 23, 2009
Messages
2
I am trying to find a way for a event in a subform to activate an event in a different subform.
The form I am working on is used to update a table called "tblTrips," which has a many-to-one relationship with a table for storing Points of Contact for certain areas, the name of which is "tblPOCs." In the form there is simple data form based subform that shows the POC information and allows for users to insert and edit POC information and also there is a combo box for selecting the POC that will be associated with the trip information.
When the user tries to type a name that isn't in tblPOCs a subform, in the form of a popup, appears and allows the user to add (but not edit) POC information.
My problem is that when the popup is used the list is not sorted and the new entry does not appear in the list until the form is reloaded or the other subform is updated. The other subform automatically updates whenever a POC is inserted or edited, and this change is reflected in the combo box's list. I would like if the popup subform triggered a sort in the other subform, since this seems to be the only way that the list will properly update in time.

Thank you in advance.
 

boblarson

Smeghead
Local time
Today, 06:57
Joined
Jan 12, 2001
Messages
32,059
1. you should be using a QUERY with a sort applied to the subform (instead of using a table and the Order By property of the form).

2. If you do that, then a simple

Forms!YourMainFormNameHere.YourSubformCONTAINERNameHere.Form.Requery

in the popup form's Close event should give you what you want.

Remember, YourSubformCONTAINERNameHere refers to the name of the control on the main form that houses the subform and not the subform name itself (unless the container control is named the exact same name as the subform).
 

rcb

New member
Local time
Today, 06:57
Joined
Jul 23, 2009
Messages
2
Thank you, I had not considered using a query, the solution works perfectly.
 

boblarson

Smeghead
Local time
Today, 06:57
Joined
Jan 12, 2001
Messages
32,059
Thank you, I had not considered using a query, the solution works perfectly.

One of the most misunderstood things about Access, for those relatively new to the program, is that you can use a query in probably 99.99% of the places you would use a table.
 

Users who are viewing this thread

Top Bottom