Consulting

Results 1 to 3 of 3

Thread: Solved: Programmatically add controls

  1. #1
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location

    Solved: Programmatically add controls

    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

    [VBA]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"[/VBA]

  2. #2
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    Actually I figured it out. I will add the code to this post when I am done for other people to use.

  3. #3
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    [VBA]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[/VBA]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •