Z
Zigs
I am creating a dynamic userform to get data from the user. The data
will be held in groups of textboxes that are created within frames. I
wouldn't have any idea how many frames the user might need, so I have
made a commandbutton that will trigger this function to add more
frames below the last one and then create the textboxes and labels in
the new frame.
However, that is not happening. The code adds the frame, with the
correct name and everything, but it will not display the labels and
textboxes. I have read through a bunch of archived threads and none
address my problem. I have also tried referencing the main big frame
that holds the sub frames to add the textbox and label controls to,
but that doesn't work either. What could be the problem?
'Add a new entry frame below the last one
Set fraFrame = fraMain.Controls.Add("Forms.Frame.1", "fraEntry" &
mlFrameCount, True)
'Set the frame's size and position
With fraFrame
.Caption = "Entry Group " & mlLessonFrameCount
.SpecialEffect = fmSpecialEffectEtched
.Top = dFraTop
.Left = 6
.Width = mlENTRY_FRAME_WIDTH
.Height = mlENTRY_FRAME_HEIGHT
End With
'Where to put the first control in the frame
dCtlTop = dFraTop + 6
'Add the entry label to the new frame
Set lblControl = fraFrame.Controls.Add("Forms.Label.1",
"lblInputNames" & mlFrameCount, True)
'Set its size and position, and caption
With lblControl
.Top = dCtlTop
.Left = 6
.Width = mlLABEL_WIDTH
.Height = mlLABEL_HEIGHT
.Caption = "Input All Required Names:"
End With
'Move to the next control position
dCtlTop = dCtlTop + mlLABEL_HEIGHT
'Add the textbox to the new frame
Set txtControl = fraFrame.Controls.Add("Forms.TextBox.1",
"txtInputNames" & mlFrameCount, True)
'Set its size and position, and caption
With txtControl
.Top = dCtlTop
.Left = 6
.Width = mlTEXTBOX_WIDTH
.Height = mlTEXTBOX_HEIGHT
.MultiLine = True
.ScrollBars = fmScrollBarsVertical
End With
will be held in groups of textboxes that are created within frames. I
wouldn't have any idea how many frames the user might need, so I have
made a commandbutton that will trigger this function to add more
frames below the last one and then create the textboxes and labels in
the new frame.
However, that is not happening. The code adds the frame, with the
correct name and everything, but it will not display the labels and
textboxes. I have read through a bunch of archived threads and none
address my problem. I have also tried referencing the main big frame
that holds the sub frames to add the textbox and label controls to,
but that doesn't work either. What could be the problem?
'Add a new entry frame below the last one
Set fraFrame = fraMain.Controls.Add("Forms.Frame.1", "fraEntry" &
mlFrameCount, True)
'Set the frame's size and position
With fraFrame
.Caption = "Entry Group " & mlLessonFrameCount
.SpecialEffect = fmSpecialEffectEtched
.Top = dFraTop
.Left = 6
.Width = mlENTRY_FRAME_WIDTH
.Height = mlENTRY_FRAME_HEIGHT
End With
'Where to put the first control in the frame
dCtlTop = dFraTop + 6
'Add the entry label to the new frame
Set lblControl = fraFrame.Controls.Add("Forms.Label.1",
"lblInputNames" & mlFrameCount, True)
'Set its size and position, and caption
With lblControl
.Top = dCtlTop
.Left = 6
.Width = mlLABEL_WIDTH
.Height = mlLABEL_HEIGHT
.Caption = "Input All Required Names:"
End With
'Move to the next control position
dCtlTop = dCtlTop + mlLABEL_HEIGHT
'Add the textbox to the new frame
Set txtControl = fraFrame.Controls.Add("Forms.TextBox.1",
"txtInputNames" & mlFrameCount, True)
'Set its size and position, and caption
With txtControl
.Top = dCtlTop
.Left = 6
.Width = mlTEXTBOX_WIDTH
.Height = mlTEXTBOX_HEIGHT
.MultiLine = True
.ScrollBars = fmScrollBarsVertical
End With