Dynamic Userform Controls not Displaying

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
 
Z

Zigs

After some trial and error I found out that the controls would not
show because of the number used for the Top property value. Within
each frame, the controls inside that frame reference their Top value
from the top of the frame. Therefore there was no need to add the
height of the other frames and controls previous. Simply start at the
top of the frame in which the controls will be housed.

I hope that makes some sense.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top