Get Subform Control Properties from Code within the Source Object (1 Viewer)

VilaRestal

';drop database master;--
Local time
Today, 10:40
Joined
Jun 8, 2011
Messages
1,046
In a module there is a function that takes a Form as an argument:

Code:
Public Function FormRecordCount(ByRef frm As Form) As Long
.
I can work out if the form is a subform by seeing if it has a parent:
Code:
    On Error Resume Next
    Dim bSubform As Boolean
    bSubform = (Len(frm.Parent.Name) > 0)
(If anyone can think of a better way to do that please say but I think that's reasonably neat.)

If it is a parent I want to know what the join fields are for the subform control (the Parent Child fields).

This is a generic function so the name of the parent isn't known at runtime let alone the name of the subform control.

Does anyone know of a way to get the name of the subform control based on the form that is its source object.

If worst comes to the worst I could loop through all the controls of the parent and find the subform with the same source object as frm.Name but that wouldn't necessarily be accurate (there could be more than one) and it would be inefficient.

Thanks in advance to anybody who can help.
 

Users who are viewing this thread

Top Bottom