Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Subform Programmatically

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
For a = 0 To Me!FieldList.ListCount - 1
If Me!FieldList.Selected(a) = True Then
Fieldname1 = Me!FieldList.ItemData(a)
' Create unbound default-size text box in detail section.
Set ctlText = CreateControl(frmMain.Name, acTextBox, , , "", intDataX, intDataY)
' Create child label control for text box.
Set ctlLabel = CreateControl(frmMain.Name, acLabel, , ctlText.Name, Fieldname1, intLabelX, intLabelY)
intLabelY = intLabelY + 300
intDataY = intDataY + 300
End If
Next

DoCmd.Restore

DoCmd.Save acForm, "Form2"

'insert sub form
' subforms Object source in Main form
Dim SourceObjectName As String
SourceObjectName = FormName & " Subform"
Set ctlLabel = CreateControl(frmMain.Name, acSubform, acDetail, frmSub.Name, SourceObjectName, 3500, 100, 6000, 2000)

I manged to add a subform object to a main form but cannot find the property to make the subforms Source Object set to a subform I just created in th etop portion of the code.

Any Ideas



DougP, MCP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top