Q
quackerbacker
I am trying to figure out the VBA code to add all of the fields in a forms
recordset.
Code execution stops at frm.Recordset.Fields.Count. The errors state that
"The expression you entered refers to an object that is closed or doesn't
exist"
This error occurs when I open the form in design view. When I open the form
as acNormal, the Recordset object is available but you cant add controls in
normal view.
Dim frm as Access.Form
Dim ctl as Control
DoCmd.OpenForm strFormName, acDesign
Set frm = Forms(strFormName)
'
'Add all fields to detail portion of form
For intCounter = 0 To frm.Recordset.Fields.Count - 1
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, ,
frm.Recordset.Fields(intCounter).Name)
Set ctl = Nothing
Next
Any help would be appreciated.
recordset.
Code execution stops at frm.Recordset.Fields.Count. The errors state that
"The expression you entered refers to an object that is closed or doesn't
exist"
This error occurs when I open the form in design view. When I open the form
as acNormal, the Recordset object is available but you cant add controls in
normal view.
Dim frm as Access.Form
Dim ctl as Control
DoCmd.OpenForm strFormName, acDesign
Set frm = Forms(strFormName)
'
'Add all fields to detail portion of form
For intCounter = 0 To frm.Recordset.Fields.Count - 1
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, ,
frm.Recordset.Fields(intCounter).Name)
Set ctl = Nothing
Next
Any help would be appreciated.