471,306 Members | 829 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,306 software developers and data experts.

binding to Combo

Rod

I have an Access database with the 3 fields in
[ID], [Last Name], [First Name]

I create a dataset and bind a form to it, no problem.

I now want to put in a combo box to search on name.
Now I can do this fine if I just use [Last Name]

But I want [Last Name] & ", " & [First Name] to appear in the combo box.

I can't see a way of getting this directly from the dataset.

I can see a way of getting it by going back to Access. But I really want to
avoid this.

any clues much appreciated.

rod

PS posted earlier to dotnet.framework.windowsforms.databinding
Jul 21 '05 #1
4 1207
Rod,

You could build an array of strings to hold the names, fill it in from the
dataset, and bind the combo box to the array, but then you're not bound to
the dataset any more, and I'm guessing you want to be bound to the dataset.

You could use a listbox instead of a combo box, if you never want the user
to enter a name that's not in the list. Listboxes can have multiple
columns.

But unless there's some strong reason not to, I'd recommend writing a query
in Access that gets you the string in the form you want it, and building
your dataset from that query.

Good luck!

Rob, providing advice that is probably not worth much more than you paid for
it.
Jul 21 '05 #2
Rod


You could use a listbox instead of a combo box, if you never want the user
to enter a name that's not in the list. Listboxes can have multiple
columns.

But unless there's some strong reason not to, I'd recommend writing a query in Access that gets you the string in the form you want it, and building
your dataset from that query.

If I add a new record I want it to appear in the combo box. OK, I can build
some logic to make it happen but I was hoping that I could make it happen
automatically. Naively I had though you could create a dataview using sql
acting on a table in the dataset.
Your list box is a good idea, I will explore that.

many thanks

Rod
Jul 21 '05 #3
Rod,

A very simple method is adding an extra column to the datatable and fill
that using an expression.

http://msdn.microsoft.com/library/de...ctortopic4.asp

That column is your displaymember.

I hope this helps?

Cor
Jul 21 '05 #4
Rod
Why did i not think of that?

Thanks

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2***************@TK2MSFTNGP14.phx.gbl...
Rod,

A very simple method is adding an extra column to the datatable and fill
that using an expression.

http://msdn.microsoft.com/library/de...ctortopic4.asp
That column is your displaymember.

I hope this helps?

Cor

Jul 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Shravan | last post: by
2 posts views Thread by SoftWhiteDelgiht | last post: by
reply views Thread by Larry Serflaten | last post: by
4 posts views Thread by Jim Shaffer | last post: by
7 posts views Thread by Nathan | last post: by
reply views Thread by Roger Odermatt | last post: by
3 posts views Thread by Max | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.