Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Going through each ComboBox line/item one by one 1

Status
Not open for further replies.

franksirvent

Programmer
Mar 8, 2002
358
GB
Hi
I have a combo box which contains 15-50 records/lines/items.

I want to go through each line with VBA so I can check whats on each record/line.

Could anyone advise whats the best/fastest way to do this?

thanks in advance
 
Take a look at the ListCount property of the ComboBox object:
For i = 0 To [name of combo].ListCount -1

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
thanks

I already got that...

What I want is now go through each record...
for example, if I have 15 records on the combobox, I want to scroll with VB from record 1 to 15

for i=1 to cmbbox.listcount-1
' HERE I NEED THE CODE WHICH MOVES THROUGH EACH RECORD...
clientname=cmbbox.column(1)

next i
 
' HERE I NEED THE CODE WHICH MOVES THROUGH EACH RECORD
Which record ?
If only the combobox is relevant, take a look at the Column property of the ComboBox object, otherwise at the RecordsetClone, FindFirst, NoMatch and Bookmark methods/properties of the Form and DAO.Recordset objects.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
ummm, the code you've got is how you get each line. You need to use the i somewhere so that the loop knows which line you are currently working on. This isn't the right syntax, but you should get the idea:

Code:
for i=1 to cmbbox.listcount-1

clientname=cmbbox[b](i)[/b].column(1)

next i

there may be some other property that you need to reference to get the "line", but you need the 'i' somewhere.

leslie
 
thanks lespaul

that's exactly the code I was looking for!
You are a life saver!!!!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top