2 Column Listbox to Textbox

modest

Registered User.
Local time
Today, 01:17
Joined
Jan 4, 2005
Messages
1,220
This is pretty self explanatory. I'm trying to set a textbox equal to my selected row of my 2-column listbox. Column1 is a city Column2 is a state.

So if the listbox has a row like:
San Diego | CA

What I have now: Me.textField.Value = Me.listBox.Column(1) & ", " & Me.listBox.Column(2) Shows: "CA, " in the textbox

If i change this to:Me.textField.Value = Me.listBox.Column(2) & ", " & Me.listBox.Column(1) I get closer with: ", CA"


#1 - How do I get my city listed
#2 - Why would column2 go before column1


Thank you in advance,
Modest
 
I would do a query that concatenates the two flds and then use the query as the row source for the list box.

Ken
 
That worked. But is there any other way? I'm a little picky :) and I liked the spacing before with the two column. All the states were aligned.

Still, I appreciate having something that works... so thank you very much.
 
Sure, Do the same thing except have three cols in the query. The city, the state and make the third col the combined value. Then in the list box make the third col 0 width. Then use it to populate the other box.

Would that work?

Ken
 
what i have at the moment is good enough... i'll try this later --- thanx again :)

I was thinking that maybe what I had originally wasn't working cuz column 1 was bound ... could this be true?
 
Your problem may be that you only have a two column combo box and access starts numbering the columns at 0, not 1. The first column would be .column(0) and the second would be .column(1).

Switch it from

Me.textField.Value = Me.listBox.Column(1) & ", " & Me.listBox.Column(2)

to

Me.textField.Value = Me.listBox.Column(0) & ", " & Me.listBox.Column(1)

or even

Me.textField.Value = Me.listBox & ", " & Me.listBox.Column(1)

That should do the trick.

Hope this helps,

Dan
 
Is that right, because I tried the column(0) before and I was getting an error. I thought it was this way at first because arrays typically start at 0... i'll give it a try again when I get back to work.

Thanks
Modest
 

Users who are viewing this thread

Back
Top Bottom