J
John Bacon
I need to have a variable number of fields on a form with different names
based upon an array of names
I've succesfully built the form using the code below InitUserFields . UF is
a dynamic array of field names UFV is a matching array of initial values for
each field.
Now I need to retrieve the values that the user enters into the form and
store them back in UFV.
I've tried to use EXECUTE & EVAL as shown in the sub GetUserFields but I
get the error sub or function not defined on ECECUTE or EVAL whichever I use.
I've included references to VB Applications Extensibility 5.3 and Excel 11.0
Object library without any difference.
Does anyone have a better idea of how to achieve this?
Sub InitUserFields(UF, UFV)
Dim X As Integer
Dim NewLabel, NewTextbox
For X = 0 To UBound(UF)
Set NewLabel = Me.Controls.Add("Forms.label.1")
With NewLabel
> Name = UF(X).Name & "Title"
> Caption = UF(X).Name
> Top = 252
> Left = 366 + X * 94
> Width = 90
> Height = 12
> Font.Name = "Tahoma"
End With
Set NewTextbox = Me.Controls.Add("Forms.textbox.1")
With NewTextbox
> Name = UF(X).Name
> Value = UFV(X)
> Top = 264
> Left = 366 + X * 94
> Width = 90
> Height = 15.75
> Font.Name = "Tahoma"
End With
Next
End Sub
Sub GetUserFields(UF, UFV)
Dim X As Integer
For X = 0 To UBound(UF)
Execute (UFV(X) = "Me." & UF(X).Name & ".Value")
Next
End Sub
based upon an array of names
I've succesfully built the form using the code below InitUserFields . UF is
a dynamic array of field names UFV is a matching array of initial values for
each field.
Now I need to retrieve the values that the user enters into the form and
store them back in UFV.
I've tried to use EXECUTE & EVAL as shown in the sub GetUserFields but I
get the error sub or function not defined on ECECUTE or EVAL whichever I use.
I've included references to VB Applications Extensibility 5.3 and Excel 11.0
Object library without any difference.
Does anyone have a better idea of how to achieve this?
Sub InitUserFields(UF, UFV)
Dim X As Integer
Dim NewLabel, NewTextbox
For X = 0 To UBound(UF)
Set NewLabel = Me.Controls.Add("Forms.label.1")
With NewLabel
> Name = UF(X).Name & "Title"
> Caption = UF(X).Name
> Top = 252
> Left = 366 + X * 94
> Width = 90
> Height = 12
> Font.Name = "Tahoma"
End With
Set NewTextbox = Me.Controls.Add("Forms.textbox.1")
With NewTextbox
> Name = UF(X).Name
> Value = UFV(X)
> Top = 264
> Left = 366 + X * 94
> Width = 90
> Height = 15.75
> Font.Name = "Tahoma"
End With
Next
End Sub
Sub GetUserFields(UF, UFV)
Dim X As Integer
For X = 0 To UBound(UF)
Execute (UFV(X) = "Me." & UF(X).Name & ".Value")
Next
End Sub