Problems setting my recordset

kermit5

Registered User.
Local time
Today, 15:41
Joined
Nov 2, 2001
Messages
122
Here is my code:

Private Sub cmdDetailsNext_Click()
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

' Set positioning values for new controls
intTabIndex = 0
intLabelX = 100
intLabelY = 100
intDataX = 1000
intDataY = 100
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
End Sub


I get a run-time error:Too few parameters. Expected 1 in the line that is red. What is it that I am missing.

Scott
 
shot in the dark try: Set rst = db.OpenRecordset("qryCreateForm",dbOpenDynaset)
 
Type Mismatch error

Thanks for the help. I now get a Run-time error: Type mismatch in the following code:

Private Sub cmdDetailsNext_Click()
Dim TxtProjextID As Integer
Dim ctlLabel As control, ctlControl As control, ctlName As Variant
Dim fldSelectedField As Field, fldFieldDataType As Field, fldFieldSize As Field
Dim FieldName As Field, fldDefaultValue As Field
Dim fld As Field
Dim intLabelX As Integer, intLabelY As Integer
Dim intDataX As Integer, intDataY As Integer
Dim intTabIndex As Integer
Dim frmTakeoff As Form
Dim rstSelectedField As DAO.Recordset
Dim dbs As DAO.Database
Dim qd As DAO.QueryDef
TxtProjectID = Forms!frmDetails!TxtProjectID

Set dbs = CurrentDb
Set qd = dbs.QueryDefs!qryCreateForm
qd.Parameters![Master Project ID] = TxtProjectID
Set rstSelectedField = qd.OpenRecordset

'Open "frmCustomForm" form in design view
DoCmd.OpenForm "frmCustomTakeoff", acDesign
Set frmTakeoff = Forms!frmCustomTakeoff

' Set positioning values for new controls
intTabIndex = 0
intLabelX = 100
intLabelY = 100
intDataX = 1000
intDataY = 100
For Each fld In rstSelectedField.Fields
ctlName = fldSelectedField.Name
Set ctlControl = CreateControl(frmTakeoff.Name, acTextBox, , , fldSelectedField.Name, intDataX, intDataY)
'Create child label control for text box
Set ctlLabel = CreateControl(fldSelectedField.Name, acLabel, , ctlControl.Name, "'" & fldSelectedField.Name & "'", intLabelX, intLabelY)
intLabelY = intLabelY + 300
intDataY = intDataY + 300
'Restore from
DoCmd.Restore
Next
End Sub


Any ideas?
Scott:confused:
 
Last edited:

Users who are viewing this thread

Back
Top Bottom