PDA

View Full Version : Solved: Programmatically add controls



Djblois
01-03-2007, 04:44 PM
I am using this code to add controls to a form. I have the first part working-adding a frame to the form but I can't seem to add the optionbuttons to the form I just added then

Dim LC, No, SBC, SBP As String
LC = "ItemCode"
No = "No"
SBC = "SortbyItem"
SBP = "SortbyProduct"
PivotTableOptions.Controls.Add bstrProgId:="Forms.Frame.1", Name:=LC, Visible:=True
PivotTableOptions.Controls(LC).Top = 157
PivotTableOptions.Controls(LC).Left = 6
PivotTableOptions.Controls(LC).Height = 70
PivotTableOptions.Controls(LC).Width = 210
PivotTableOptions.Controls(LC).Caption = "Do you want Item code in the Report?"
PivotTableOptions.Itemcode.Controls.Add bstrProgId:="Forms.optionbutton.1", Name:=No, Visible:=True
PivotTableOptions.Itemcode.Controls(LC).Top = 10
PivotTableOptions.Itemcode.Controls.Left = 6
PivotTableOptions.Itemcode.Controls.Height = 10
PivotTableOptions.Itemcode.Controls(LC).Width = 10
PivotTableOptions.Itemcode.Controls(LC).Caption = "No"

Djblois
01-03-2007, 05:09 PM
Actually I figured it out. I will add the code to this post when I am done for other people to use.

Djblois
01-03-2007, 06:04 PM
LC = "ItemCode"
No = "NoItemNumber"
SBI = "SortbyItem"
SBP = "SortbyProduct"
PivotTableOptions.Controls.Add bstrProgId:="Forms.Frame.1", Name:=LC, Visible:=True
PivotTableOptions.Controls(LC).Top = 157
PivotTableOptions.Controls(LC).Left = 6
PivotTableOptions.Controls(LC).Height = 70
PivotTableOptions.Controls(LC).Width = 210
PivotTableOptions.Controls(LC).Caption = "Do you want Item# in the Report?"
PivotTableOptions.Controls(LC).Font.Bold = True
PivotTableOptions.Controls(LC).Add bstrProgId:="Forms.optionbutton.1", Name:=SBP, Visible:=True
PivotTableOptions.Controls(SBP).Top = 14
PivotTableOptions.Controls(SBP).Left = 12
PivotTableOptions.Controls(SBP).Height = 14
PivotTableOptions.Controls(SBP).Width = 120
PivotTableOptions.Controls(SBP).Caption = "Yes, Sort by Product"
PivotTableOptions.Controls(SBP).Font.Bold = True
PivotTableOptions.Controls(SBP).GroupName = Itemcode


PivotTableOptions.Controls(LC).Add bstrProgId:="Forms.optionbutton.1", Name:=SBI, Visible:=True
PivotTableOptions.Controls(SBI).Top = 38
PivotTableOptions.Controls(SBI).Left = 12
PivotTableOptions.Controls(SBI).Height = 14
PivotTableOptions.Controls(SBI).Width = 120
PivotTableOptions.Controls(SBI).Caption = "Yes, Sort by Item#"
PivotTableOptions.Controls(SBI).Font.Bold = True
PivotTableOptions.Controls(SBI).GroupName = Itemcode

PivotTableOptions.Controls(LC).Add bstrProgId:="Forms.optionbutton.1", Name:=No, Visible:=True
PivotTableOptions.Controls(No).Top = 27
PivotTableOptions.Controls(No).Left = 140
PivotTableOptions.Controls(No).Height = 14
PivotTableOptions.Controls(No).Width = 30
PivotTableOptions.Controls(No).Caption = "No"
PivotTableOptions.Controls(No).Font.Bold = True
PivotTableOptions.Controls(No).Value = True
PivotTableOptions.Controls(No).GroupName = Itemcode