Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook - Using Forms (http://www.outlookbanter.com/outlook-using-forms/)
-   -   Dynamic fields on forms (http://www.outlookbanter.com/outlook-using-forms/95311-dynamic-fields-forms.html)

John Bacon September 25th 09 02:30 PM

Dynamic fields on forms
 
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

Sue Mosher [MVP][_3_] September 25th 09 02:35 PM

Dynamic fields on forms
 
Sorry, but I don't see what this has to do with Outlook custom forms.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"John Bacon" wrote in message
...
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




John Bacon September 25th 09 02:39 PM

Dynamic fields on forms
 
Silly me, as soon as I'd posted I saw the answer after spending the previous
4 hours loking for a solution.

Sub GetUserFields(UF, UFV)
Dim X As Integer
For X = 0 To UBound(UF)
UFV(X) = Me.Controls(UF(X).Name).Value
Next
End Sub

"John Bacon" wrote:

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


John Bacon September 25th 09 02:44 PM

Dynamic fields on forms
 
Well in my eyes it's a formin OUTLOOK customised by VBA, but maybe I don't
understand what Outlook custom forms implies, in which case please point me
to the correct forum in case I get another problem in future.
Thanks.

"Sue Mosher [MVP]" wrote:

Sorry, but I don't see what this has to do with Outlook custom forms.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"John Bacon" wrote in message
...
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





Sue Mosher [MVP][_3_] September 25th 09 02:56 PM

Dynamic fields on forms
 
Outlook custom forms are the UI/code templates for Outlook message, contact,
and other items. They're quite different from VBA user forms. Questions
about those go in the microsoft.public.outlook.program_vba newsgroup.

And, please, always include your version of Outlook when you post.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"John Bacon" wrote in message
...
Well in my eyes it's a formin OUTLOOK customised by VBA, but maybe I don't
understand what Outlook custom forms implies, in which case please point
me
to the correct forum in case I get another problem in future.
Thanks.

"Sue Mosher [MVP]" wrote:

Sorry, but I don't see what this has to do with Outlook custom forms.

"John Bacon" wrote in message
...
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







John Bacon September 28th 09 09:02 AM

Dynamic fields on forms
 
Sue,
Thanks for that info. Strange thing is I started in that group and got
directed to this one. Anyway I've got the solution so that's the most
important thing.

"Sue Mosher [MVP]" wrote:

Outlook custom forms are the UI/code templates for Outlook message, contact,
and other items. They're quite different from VBA user forms. Questions
about those go in the microsoft.public.outlook.program_vba newsgroup.

And, please, always include your version of Outlook when you post.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"John Bacon" wrote in message
...
Well in my eyes it's a formin OUTLOOK customised by VBA, but maybe I don't
understand what Outlook custom forms implies, in which case please point
me
to the correct forum in case I get another problem in future.
Thanks.

"Sue Mosher [MVP]" wrote:

Sorry, but I don't see what this has to do with Outlook custom forms.

"John Bacon" wrote in message
...
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








All times are GMT +1. The time now is 07:55 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com