PC Review


Reply
Thread Tools Rate Thread

binding to Combo

 
 
Rod
Guest
Posts: n/a
 
      23rd Feb 2005

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


 
Reply With Quote
 
 
 
 
Rob Richardson
Guest
Posts: n/a
 
      23rd Feb 2005
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.


 
Reply With Quote
 
Rod
Guest
Posts: n/a
 
      24th Feb 2005


>
> 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


 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      24th Feb 2005
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


 
Reply With Quote
 
Rod
Guest
Posts: n/a
 
      24th Feb 2005
Why did i not think of that?

Thanks



"Cor Ligthert" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo Box Binding Gajanan Microsoft Access Form Coding 1 17th Dec 2007 05:49 AM
Binding a Combo Box pcstechnical.sfhs@gmail.com Microsoft Access Forms 5 25th Sep 2007 08:26 PM
binding to a combo box NCiii Microsoft VB .NET 2 18th Jun 2004 06:57 PM
binding to a combo box Geraldine Hobley Microsoft VB .NET 1 22nd Dec 2003 03:59 PM
binding to a combo box Robert Batt Microsoft Dot NET Framework Forms 0 21st Oct 2003 02:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:51 AM.