I am trying to create a custom wizard that enables the user to select fields from a list that he/she wants to include on a form. The field properties are in a table tblAvailableFields and include FieldName, FieldType (Control Type i.e. acTextbox, acComboBox, etc.), FieldWidth, FieldRecordSource, etc.
Here is a portion of my code:
Dim frm As Form
Dim ctlLabel As control, ctlControl As control, ctlName As Variant
Dim intLabelX As Integer, intLabelY As Integer
Dim intDataX As Integer, intDataY As Integer
Dim intTabIndex As Integer
Dim fld As Field
Dim rst As Recordset
Dim db As Database
Set db = CurrentDb
Set rst = db.OpenRecordset("qryCreateForm")
'Set ProjectName Value
ProjectName = Forms!frmDetails!txtProjectName
'Open "frmCustomForm" form in design view
DoCmd.OpenForm "frmCustomTakeoff", acDesign
Set frm = Forms!frmCustomTakeoff
For Each fld In rst.Fields
ctlName = fld.Name
Set ctlControl = CreateControl(frm.Name, acTextBox, , , fld.Name, intDataX, intDataY)
'Create child label control for text box
Set ctlLabel = CreateControl(fld.Name, acLabel, , ctlControl.Name, "'" & fld.Name & "'", intLabelX, intLabelY)
intLabelY = intLabelY + 300
intDataY = intDataY + 300
'Restore from
DoCmd.Restore
Next
In the blue line, in place of "acTextBox" I would like to place the value for that recordset so each field will have the pre-determined control type. How do I reference that value?
Scott
Here is a portion of my code:
Dim frm As Form
Dim ctlLabel As control, ctlControl As control, ctlName As Variant
Dim intLabelX As Integer, intLabelY As Integer
Dim intDataX As Integer, intDataY As Integer
Dim intTabIndex As Integer
Dim fld As Field
Dim rst As Recordset
Dim db As Database
Set db = CurrentDb
Set rst = db.OpenRecordset("qryCreateForm")
'Set ProjectName Value
ProjectName = Forms!frmDetails!txtProjectName
'Open "frmCustomForm" form in design view
DoCmd.OpenForm "frmCustomTakeoff", acDesign
Set frm = Forms!frmCustomTakeoff
For Each fld In rst.Fields
ctlName = fld.Name
Set ctlControl = CreateControl(frm.Name, acTextBox, , , fld.Name, intDataX, intDataY)
'Create child label control for text box
Set ctlLabel = CreateControl(fld.Name, acLabel, , ctlControl.Name, "'" & fld.Name & "'", intLabelX, intLabelY)
intLabelY = intLabelY + 300
intDataY = intDataY + 300
'Restore from
DoCmd.Restore
Next
In the blue line, in place of "acTextBox" I would like to place the value for that recordset so each field will have the pre-determined control type. How do I reference that value?
Scott