+ Reply to Thread
Results 1 to 2 of 2

Combo box error on form

Hybrid View

  1. #1
    leaper@false.com
    Guest

    Combo box error on form

    Hi
    I'm having a problem with a form, I use a combo box to select values from,
    but when I read the cell on the work sheet it refers to, it the cell is
    empty it come up with an error. I thought that - Subsyst.AddItem "" ,
    would handle it but it doesn't, any help would be appreciated


    this is the code I use to populate the combo box

    Private Sub addSubsyst()
    Subsyst.AddItem ""
    Subsyst.AddItem "S01" 'ListIndex = 1
    Subsyst.AddItem "S02" 'ListIndex = 2
    Subsyst.AddItem "S03" 'ListIndex = 3
    Subsyst.AddItem "S04" 'ListIndex = 4
    Subsyst.AddItem "S05" 'ListIndex = 5
    Subsyst.AddItem "S06" 'ListIndex = 6
    Subsyst.AddItem "S07" 'ListIndex = 7
    Subsyst.AddItem "S08" 'ListIndex = 8
    Subsyst.AddItem "S09" 'ListIndex = 9
    Subsyst.AddItem "S10" 'ListIndex = 10
    Subsyst.AddItem "S12" 'ListIndex = 11
    Subsyst.AddItem "N/A" 'ListIndex = 12


    'Use drop-down list
    Subsyst.Style = fmStyleDropDownList
    'Combo box values are ListIndex values
    Subsyst.BoundColumn = 0
    'Set combo box to first entry


    Subsyst.Width = 60
    Subsyst.ListWidth = 55

    End Sub

    And this to read from the work sheet to populate the form with data

    Private Sub getmine()
    Select Case itmnum
    Case 4 To LastRow - 1
    Itemnumbx.Text = Cells(itmnum, 1)
    Itemdescr.Text = Cells(itmnum, 2)
    Spec.Text = Cells(itmnum, 3)
    Wesnum.Text = Cells(itmnum, 4)
    Locat.Text = Cells(itmnum, 5)
    valadd.Text = Cells(itmnum, 6)
    evatxt.Text = Cells(itmnum, 7)
    nvatxt.Text = Cells(itmnum, 8)
    walk.Text = Cells(itmnum, 9)
    auto.Text = Cells(itmnum, 10)
    ComboBox1 = Cells(itmnum, 11)
    Subsyst.Text = Cells(itmnum, 18)

    Case Else
    Itemnumbx.Text = itmnum - 3
    ClearData

    End Select
    DisableSave

    End Sub

  2. #2
    leaper@false.com
    Guest

    Re: Combo box error on form

    I've just worked out what was wrong,

    I had the style set as a dropdownlist instead of a combobox, so it would
    not let me enter new items

    Thanks

    kev Q

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1