Here is my code:
Private Sub cmdDetailsNext_Click()
'**************************************************************************
'*This sub takes the information entered by the user for the project takeoff
'*and creates a new form.
'*
'**************************************************************************
Dim dbs As Database
Dim rst As Recordset
Dim qdf As QueryDef
Dim fld As Field
Dim frm As Form
Dim control As control
Dim DesignForm As String
Dim NewFormName As String
Dim Buffer As String
Dim bytChoice As Byte
Dim LeftCoord As Integer
Dim TopCoord As Integer
Dim Width As Integer
If IsNull(rst) Then Exit Sub 'run only if records are available
'The following code creates the new form and saves it with a unique _
name, determined by the time it was created.
Set frm = CreateForm
frm.RecordSource = "qryCreateForm"
Buffer = Now()
NewFormName = frm.Name
DesignForm = [ProjectName] & " " & Buffer
DoCmd.Save acForm, NewFormName
DoCmd.Close acForm, NewFormName
DoCmd.Rename DesignForm, acForm, NewFormName
'The following lines open the form in design view and add fields to form
DoCmd.OpenForm DesignForm, acDesign
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("qryCreateForm")
Set rst = qdf.OpenRecordset()
LeftCoord = 1000
TopCoord = 100
Width = 500
For Each fld In rst.Fields
If fld.Name = "Closer" Then
Set control = CreateControl(DesignForm, [FieldControlType], , " ", fld.Name, _
LeftCoord, TopCoord, Width)
End If
Next fld
End Sub
I get the error in the line marked with the frown. I don't seem to see what is missing.
Any ideas?
Private Sub cmdDetailsNext_Click()
'**************************************************************************
'*This sub takes the information entered by the user for the project takeoff
'*and creates a new form.
'*
'**************************************************************************
Dim dbs As Database
Dim rst As Recordset
Dim qdf As QueryDef
Dim fld As Field
Dim frm As Form
Dim control As control
Dim DesignForm As String
Dim NewFormName As String
Dim Buffer As String
Dim bytChoice As Byte
Dim LeftCoord As Integer
Dim TopCoord As Integer
Dim Width As Integer
If IsNull(rst) Then Exit Sub 'run only if records are available
'The following code creates the new form and saves it with a unique _
name, determined by the time it was created.
Set frm = CreateForm
frm.RecordSource = "qryCreateForm"
Buffer = Now()
NewFormName = frm.Name
DesignForm = [ProjectName] & " " & Buffer
DoCmd.Save acForm, NewFormName
DoCmd.Close acForm, NewFormName
DoCmd.Rename DesignForm, acForm, NewFormName
'The following lines open the form in design view and add fields to form
DoCmd.OpenForm DesignForm, acDesign
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("qryCreateForm")
LeftCoord = 1000
TopCoord = 100
Width = 500
For Each fld In rst.Fields
If fld.Name = "Closer" Then
Set control = CreateControl(DesignForm, [FieldControlType], , " ", fld.Name, _
LeftCoord, TopCoord, Width)
End If
Next fld
End Sub
I get the error in the line marked with the frown. I don't seem to see what is missing.
Any ideas?