Combo box error on form

L

leaper

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
 
L

leaper

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
 

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