I managed to type a function call with variable form names like this:
call from form/procedure:
Dim strMainform As String
Dim strSubformControlName As String
Dim strControlName As String
strMainform = "f_trip_header"
strSubformControlName = "varform"
strControlName = "f_trip_details"
Forms(strMainform)(strSubformControlName).Visible = True
Call variableform(strMainform, strSubformControlName, strControlName)
Forms(strMainform)(strSubformControlName).LinkMasterFields = "Counter"
Forms(strMainform)(strSubformControlName).LinkChildFields = "parentlink"
actual function in module1/formutilites:
Public Function variableform(strMainform As String, strSubformControlName As String, strControlName As String)
'mainform: form1
'subform: subform
'sourceobject: f_customer
MsgBox (strMainform & " " & strSubformControlName & " " & strControlName)
Forms(strMainform)(strSubformControlName).SourceObject = (strControlName)
This was a tough one and I hope some folks can benefit from this little function that dynamically allows you open subforms.