A generalized way to synchronize forms

  • Thread starter Thread starter Rene
  • Start date Start date
R

Rene

Hello,

I am looking for 'a generalized way to synchronize the forms'.My application
has many forms being opened an any given time, and each can be opened or
closed at will during a user session. Finally, they need to be synchronized
with each
other in the data they display.

To exemplify, for each of the following, a form exists listing (in a
Listview control) relevant data:
- Customer list
- Order list, for a customer
- Order detail, for an order
- Aircraft list
- Flight list, for an aircraft
- Passenger list, on a flight

Clicking on a customer:
- lists orders, for the selected customer
- lists order detail, for customer's first order if one exists
- highlights passenger list entry, if customer is booked on flight currently
displayed

...., I'm sure you get the idea, many forms, displaying data based on a 'key'
from another form.

The usual way to achieve synchronization is by sinking to event handlers in
the forms that need to react to events from other forms. As I understand
it, this entails defining objects, and writing event handlers in the forms
that do the 'listening'. This process gets messy when forms are opened and
closed at will, as a form might wind up listening to nothing!

I'm looking for a generalized - and hopefully simpler way; maybe with a
single 'Watchdog' form to handle all the synchronization.

I'll much appreciate comments, ideas, links, articles, suggested reading,
etc...

Thanx!

René
Montreal
 
Never had to deal with a like situation. Would something as
simple as putting a Me.Refresh or Me.Requery on a timer
event on the master forms work?

Gary Miller
 
.... or the Activate event of the forms.

- Steve Schapel, Microsoft Access MVP
 
Thank your for the replies!

ON: Requery/Refresh in timer event of 'master' forms:
This is indeed a way out - with a couple of side effects.
1- The forms will be updated asynchronously, ie. with some delay; unless the
timer interval were very short, in which case CPU/Net resources used
increase.
2- I hadn't mentioned originally, but the back-end data sits on a server
machine different than the client front-end. This makes me leary of firing
refreshes/requeries in a timer event.

ON: Requery/Reresh in activate event:
Also a possibility. In this case however, if I understand the activate
event correctly, the updated data only shows up when the involved form
re-receives the focus. So less than ideal.

Thanks again, and I'm still looking!

René
 
You may want to try the bookmark approach. Some sample code is below:

Private Sub Form_Current()
Dim frm As Form, rst As Recordset
'synch frmPersonEdit to this form
If Not IsLoaded("frmPersonEdit") Then
DoCmd.OpenForm "frmPersonEdit", , , , acHidden
End If
Set frm = Forms!frmPersonEdit
Set rst = frm.RecordsetClone
With rst
rst.FindFirst "[PersonID] = " & Me.txtPersonID
If rst.NoMatch Then
MsgBox "No match was found. Remove filter/sort and retry "
Else
frm.Bookmark = rst.Bookmark
End If
rst.Close
End With
End Sub

Hope this helps.


--
Allan Thompson
APT Associates/ FieldScope LLC
MS Office Automation / Measurement and Reporting Systems
www.fieldscope.com
860.242.4184
 
Back
Top