I made a test database to illustrate my problem:
Views: 9 Size: 70.7 KB">subform tests.zip
I have two tables, Table1 and Table2, that have a one-to-many relationship. I made a form named "Main Form 1" which sets up the two tables as main form and subform. Everything works as it should. Note that the child records on the subform show up almost instantaneously whenever I move to a different record on the main form.
But then I made a "Main Form 2" that sets up the two tables as two SUBFORMS:
The form is set up so that when I click on a record on Table1 subform, the child records of the Table2 subform appears. This is done by setting the link master & child fields in Table2 subform's property sheet.
My problem is that the child records take HALF A SECOND (or more) to appear. I click on a record on Table1 subform, child records on Table2 subform appear half a second later. Click on another row on Table1 subform, another half second wait.
Anyone know why there is such a delay and is there any way to eliminate or minimize it? Note that it doesn't matter how many child records there are to show. Even if there is only one child record to show, the delay still occurs.
---------
My workaround currently is NOT to use the link master & child fields in Table2 subform's properties. I set the link fields to blanks. Then I go to Table1 subform's OnCurrent event and CHANGE Table2 subform's RecordSource directly:
And the result is in "Main Form 3" of my database. The child records appear INSTANTLY every time I select a record in Table1 subform.Code:Private Sub Form_Current() ' Ignore error caused by "Table2 subform" not being loaded On Error Resume Next ' Change record source of "Table2 subform" directly Forms![Main Form 3]![Table2 subform].Form.RecordSource = "SELECT * FROM Table2 WHERE ID=" & Me!ID End Sub
I'm beginning to implement this workaround in several of my projects, whenever performance becomes an important issue.
But I still would like to know why such a performance hit occurs only in a subform-subform setup, but NOT in a mainform-subform setup. Don't the two setups use the same kind of link master & child fields?