combo box with 2 fields

data_analyst
10-06-2000, 09:21 PM
OK here we go. I have a table in an Access97 database that has 2 fields in it. I would like to populate a combo box with BOTH of those fields. Currently i am using 1 box for each field. Please help. Below is some code that i am using for the singles.

Private sub My_Sub()
set db = workspaces (0). opendatabase ("Full Path Name")
set rs = db.openrecordset ("Table", dbopentable)
do until rs.eof
combobox.additem rs.fields ("Field Name", dbopentable)
rs.movenext
Loop
rs.close
db.close
set rs = nothing
set db = nothing
end sub

Again, thank you for any help!

BillSoo
10-07-2000, 02:44 AM
You mean you want both fields in the same line? How about just adding them with a space between?

eg.

.additem field1 & " " & field2

"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder

Flamelord
10-17-2000, 09:00 AM
I have had similar situation before where I have a table that contains a list of items I want to show in a combo. The three fields are ID,Caption,Description. I add the item to the combo with the text of the Caption field and set the ItemData property to the ID.

On the combo click event, I set the ToolTip text to the Description field for the item that is selected. This gives a passive, non-intrusive extended description of what is selected.

whelanp
10-17-2000, 09:21 AM
Very good idea using the tooltip text like that.

Like it a lot.

whelanp
10-17-2000, 09:32 AM
The problem I've always found when just adding a space between 2 fields for a combo is that if the the data items vary lots in length it makes it very hard to read.

eg

123 abcdefg
12443434 wfsdfsfsff
2323 weweqweqweqwe


There is a way around this using fixed size fonts ie fonts where all chars are the same.

Got an API routine somewhere for doing this.

However I would go with the tooltip text method.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum