Reputation: 2412
I've got a subform buried under a number of levels and am have trouble referencing it.
If we call this subform I'm trying to get to CourseSubForm2, it is on the second page of tab control CourseTabControlPage2, the tab control is on a subform CourseSubForm1 and then that subform is on the main form EnrolMainForm.
Or, as a tree:
EnrolMainForm
- CourseSubForm1
- CourseTabControlPage2 (<- this is the name of the tab page, not the whole tab control)
- CourseSubForm2
I'm basically trying to get the record count of what's currently on display in CourseSubForm2 and then put that in the .Caption
property of the second page of the control tab.
My attempt::
Public Sub EnrolCompAims()
Dim EnrolCompAims As String
EnrolCompAims = Trim(Forms![EnrolMainForm]![CourseSubForm1].Form![CourseSubForm2].Form.RecordsetClone.RecordCount)
Forms![EnrolMainForm]![CourseSubForm1].Form![CourseTabControlPage2].Caption = "Component Aims (" & EnrolCompAims & ")"
End Sub
No error is occurring with my above attempt, but the EnrolCompAims
is equating to 0. The record I'm testing this on has 4 records in the subform that the RecordCount
is being applied to.
Upvotes: 1
Views: 69
Reputation: 2412
Fixed.
My referencing was fine, but I was calling my EnrolComAims()
sub routine from the current event of my main form. I guess that event occurs before records are loaded in CourseSubForm2 subform.
I called EnrolComAims()
from the current event of CourseSubForm2 and now it works fine.
Upvotes: 2