Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Dynamic Userform Controls not Displaying
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Dynamic Userform Controls not Displaying
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. On Apr 22, 12:06 pm, Zigs wrote: 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 . . . I have thought about making the command button display another userform on the top of this one to collect the same info. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Multiple Controls in a Dynamic UserForm | Excel Programming | |||
Dynamic Controls (CheckBox) using VBA in Excel | Excel Programming | |||
Dynamic controls | Excel Programming | |||
creating dynamic controls | Excel Programming | |||
Dynamic Label for Controls | Excel Programming |