Dear Marshall
To answer the question of binding the forms, yes, I also use a routine to
bind the controls and of course the form's record source to the dynamically
created sql string. Here is the code:
Public Function displayVarform(strmainform, strSubformcontrol,
strControlname, strChildFields, strMasterFields, strRecordsource)
Call bindvarform(strmainform, strSubformcontrol)
Forms(strmainform)(strSubformcontrol).SourceObject = (strControlname)
Forms(strmainform)(strSubformcontrol).SourceObject = (strControlname)
Forms(strmainform)(strSubformcontrol).Form.RecordSource = (strRecordsource)
On Error Resume Next
Forms(strmainform)(strSubformcontrol).LinkMasterFields = strMasterFields
On Error Resume Next
Forms(strmainform)(strSubformcontrol).LinkChildFields = strChildFields
End Function
Public Function DisplaySubVarform(strmainform, strSubformcontrol,
strSubformControl1, strControlname, strChildFields, strMasterFields,
strRecordsource)
MsgBox ("Rec Source: " & strRecordsource)
MsgBox ("strControlName: " & strControlname)
Forms(strmainform)(strSubformcontrol)(strSubformControl1).SourceObject =
(strControlname)
Forms(strmainform)(strSubformcontrol)(strSubformControl1).Form.RecordSource =
(strRecordsource)
Forms(strmainform)(strSubformcontrol)(strSubformControl1).Form.AllowAdditions
= True
'On Error Resume Next
'Forms(strMainForm)(strSubformControl)(strSubformControl1).LinkMasterFields =
strMasterFields
'On Error Resume Next
'Forms(strMainForm)(strSubformControl)(strSubformControl1).LinkChildFields =
strChildFields
End Function
Public Function displayVarformUnlinked(strmainform, strSubformcontrol,
strControlname)
Forms(strmainform)(strSubformcontrol).SourceObject = (strControlname)
End Function
Public Function blank_fields(strForm)
Dim i As Integer
For i = 0 To Forms(strForm).Controls.Count - 1
If Forms(strForm).Controls(i).Tag = 1 Or Forms(strForm).Controls(i).Tag
= 2 Then
Forms(strForm).Controls(i).ControlSource = Forms(strForm).Controls(i).Name
Else
End If
Next i
End Function
Public Function unbound(strForm)
Dim i As Integer
For i = 0 To Forms(strForm).Controls.Count - 1
Select Case Forms(strForm).Controls(i).Tag
Case 1, 2, 3
Forms(strForm).Controls(i).ControlSource = ""
End Select
Next i
End Function
Public Function unboundvarform(strForm, strControlForm)
Dim i As Integer
For i = 0 To Forms(strForm)(strControlForm).Controls.Count - 1
Select Case Forms(strForm)(strControlForm).Controls(i).Tag
Case 1, 2, 3
Forms(strForm)(strControlForm).Controls(i).ControlSource = ""
End Select
Next i
End Function
Public Function UnboundSubVarform(strForm, strControlForm, strControlForm1)
Dim i As Integer
For i = 0 To Forms(strForm)(strControlForm)(strControlForm1).Controls.Count
- 1
Select Case Forms(strForm)(strControlForm)(strControlForm1).Controls(i).Tag
Case 1, 2, 3
Forms(strForm)(strControlForm)(strControlForm1).Controls(i).ControlSource = ""
End Select
Next i
End Function
Public Function clearfields(strForm)
Dim i As Integer
For i = 0 To Forms(strForm).Controls.Count - 1
Select Case Forms(strForm).Controls(i).Tag
Case 1, 2, 3
Forms(strForm).Controls(i) = ""
End Select
Next i
End Function
Public Function detach(strForm)
Dim i As Integer
Forms(strForm).RecordSource = ""
End Function
Public Function bind(strForm)
Dim i As Integer
For i = 0 To Forms(strForm).Controls.Count - 1
Select Case Forms(strForm).Controls(i).Tag
Case 1, 2, 3
Forms(strForm).Controls(i).ControlSource = Forms(strForm).Controls(i).Name
End Select
Next i
End Function
Public Function AttachForm(strForm, strRecordsource)
Forms(strForm).RecordSource = (strRecordsource)
End Function
Public Function DetachVarform(strmainform, strSubformcontrol, strControlname)
Forms(strmainform)(strSubformcontrol).Form.RecordSource = ""
End Function
Public Function DetachSubVarform(strmainform, strSubformcontrol,
strSubformControl1, strControlname)
Forms(strmainform)(strSubformcontrol)(strSubformControl1).Form.RecordSource
= ""
End Function
Public Function ClearFieldsVarform(strmainform, strSubformcontrol)
Dim i As Integer
For i = 0 To Forms(strmainform)(strSubformcontrol).Controls.Count - 1
Select Case Forms(strmainform)(strSubformcontrol).Controls(i).Tag
Case 1, 2, 3
Forms(strmainform)(strSubformcontrol).Controls(i) = ""
End Select
Next i
End Function
Public Function ClearFieldsSubVarform(strmainform, strSubformcontrol,
strSubformControl1)
Dim i As Integer
For i = 0 To
Forms(strmainform)(strSubformcontrol)(strSubformControl1).Controls.Count - 1
Select Case
Forms(strmainform)(strSubformcontrol)(strSubformControl1).Controls(i).Tag
Case 1, 2, 3
Forms(strmainform)(strSubformcontrol)(strSubformControl1).Controls(i) = ""
End Select
Next i
End Function
Public Function bindvarform(strmainform, strSubformcontrol)
Dim i As Integer
For i = 0 To Forms(strmainform)(strSubformcontrol).Controls.Count - 1
Select Case Forms(strmainform)(strSubformcontrol).Controls(i).Tag
Case 1, 2, 3
Forms(strmainform)(strSubformcontrol).Controls(i).ControlSource
= Forms(strmainform)(strSubformcontrol).Controls(i).Name
End Select
Next i
End Function