Question Locked

ms access 2003 form/subform

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Dear All

I am trying to have dynamic subforms whereby the variables for the relevant subforms are dynamically assigned by the program.

Would anyone know how to go about this?

All efforts like me!sub.controls = "f_customer_details1" etc. failed.

Rgds

3 replies

by sgt_shultz

are you able to download the sample access forms from dwww.microsoft.com/downloads

HIH you get started.

by bernie

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.

This discussion is closed to new replies.