binding to Combo

  • Thread starter Thread starter Rod
  • Start date Start date
R

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
 
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.
 
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
 
Back
Top