Howdy Everyone . . . . .
Without getting too deep, the [blue]
Access Form Wizard[/blue] is restricted to synchronizing a [blue]mainForm with subform(s) only![/blue]. The [purple]Type View[/purple] (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:
[ol][li]A continuous view mainform to synchronize a continuous view subform.[/li]
[li]A continuous view subform to synchronize another continuous view subform.[/li]
[li]A mainform or subform to synchronize any other form.[/li][/ol]
For one form [blue]to be dependent on another[/blue], it has to be synchronized. There are several methods to do this. The one I present here allows [blue]synchronization even after both forms are open[/blue] (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 ([purple]don't forget to backup the database in case you want to come back to square one[/purple]).
Note: In any code, [blue]
you![/blue] substitute all names in [purple]
purple[/purple].
Note: Here after the [blue]main form[/blue] is referred to as the [purple]
Master[/purple]. The [blue]dependent form[/blue] (controlled form) is referred to as the [purple]
Slave[/purple].
[ol][li]If the Slave is a subform, Open its [blue]parent or main form[/blue], call up the form properties, click the [blue]Data Tab[/blue], then click the subForm control. Remove any text in the [blue]Link Master/Child[/blue] properties. Set the [blue]Default View[/blue] as desired. Save & Close the form.[/li]
[li]Make a query for the [blue]Slave[/blue] with the fields you desire. Be sure to [blue]include a field common to both Master & Slave[/blue] (usually the PrimaryKey . . . in fact thats what I use in the example code). Stay in Query Design View.[/li]
[li]In the [blue]criteria for PrimaryKey[/blue] add the following:
Code:
[blue]Forms![purple][b]MasterFormName[/b][/purple]![purple][b]PrimaryKeyName[/b][/purple][/blue]
[/li]
[li]Save & name the query.[/li]
[li]Open the [blue]Slave[/blue] in design view and in the [blue]RecordSource[/blue] property of the form, select the query from the dropdown list. [blue]Then set the Default View as desired![/blue][/li]
[li]Save/Close the form.[/li]
[li]If your controlling a subform goto the next step, otherwise continue.
The Master needs to detect if the Slave is open. If it is, [blue]
synchronization is performed by a simple Requery of the Slave![/blue] So in a module in the modules window add the following code:
Code:
[blue]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[/blue]
[/li]
[li]Finally, in the [blue]On Current[/blue] event of the [blue]Master[/blue] add the following.
[ol a][li][blue]If your controlling an external form[/blue] (non subform):
Code:
[blue] If IsOpenFrm("[purple][b]SlaveFormName[/b][/purple]") Then
Forms![purple][b]SlaveFormName[/b][/purple].Requery
End If[/blue]
[/li]
[li]If your [blue]controlling a subform[/blue]:
Code:
[blue] Me![purple][b]SlaveFormName[/b][/purple].Requery[/blue]
[/li][/ol][/li][/ol]
For external slave forms (on subform), however you decide to open the [blue]Slave[/blue], don't do anything special, just open it (like DoCmd.OpenForm "SlaveFormName"). It'll automatically synchronize on open!
[purple]Thats it. Give it a whirl and let me know . . . .[/purple]