Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Microsoft: Access Forms FAQ

User Interface Techniques

How to Synchronize Forms . . . Your Way! by TheAceMan1
Posted: 9 May 05 (Edited 8 Jun 05)

Howdy Everyone . . . . .

Without getting too deep, the Access Form Wizard is restricted to synchronizing a mainForm with subform(s) only!. The Type View (single/continuous) of this mainform/subform combination is further restricted. No means is provided to synchronize a form seperate/external to the mainform.

Maybe you want:
  1. A continuous view mainform to synchronize a continuous view subform.
  2. A continuous view subform to synchronize another continuous view subform.
  3. A mainform or subform to synchronize any other form.
For one form to be dependent on another, it has to be synchronized. There are several methods to do this. The one I present here allows synchronization even after both forms are open (most other methods synchronize the dependent form only on open). Goto to a record on the MainForm and the DependentForm synchronizes (follows along).

Now the process (don't forget to backup the database in case you want to come back to square one).

Note: In any code, you! substitute all names in purple.
Note: Here after the main form is referred to as the Master. The dependent form (controlled form) is referred to as the Slave.

  1. If the Slave is a subform, Open its parent or main form, call up the form properties, click the Data Tab, then click the subForm control. Remove any text in the Link Master/Child properties. Set the Default View as desired. Save & Close the form.
  2. Make a query for the Slave with the fields you desire. Be sure to include a field common to both Master & Slave (usually the PrimaryKey . . . in fact thats what I use in the example code). Stay in Query Design View.
  3. In the criteria for PrimaryKey add the following:


  4. Save & name the query.
  5. Open the Slave in design view and in the RecordSource property of the form, select the query from the dropdown list. Then set the Default View as desired!
  6. Save/Close the form.
  7. If your controlling a subform goto the next step, otherwise continue.
    The Master needs to detect if the Slave is open. If it is, synchronization is performed by a simple Requery of the Slave! So in a module in the modules window add the following code:


    Function IsOpenFrm(frmName As String) As Boolean
       Dim cp As CurrentProject, Frms As Object
       Set cp = CurrentProject()
       Set Frms = cp.AllForms
       If Frms.Item(frmName).IsLoaded Then
          If Forms(frmName).CurrentView > 0 Then IsOpenFrm = True
       End If
       Set Frms = Nothing
       Set cp = Nothing

    End Function
  8. Finally, in the On Current event of the Master add the following.
    1. If your controlling an external form (non subform):


         If IsOpenFrm("SlaveFormName") Then
         End If
    2. If your controlling a subform:


For external slave forms (on subform), however you decide to open the Slave, don't do anything special, just open it (like DoCmd.OpenForm "SlaveFormName"). It'll automatically synchronize on open!
Thats it. Give it a whirl and let me know . . . .

Back to Microsoft: Access Forms FAQ Index
Back to Microsoft: Access Forms Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close