472,989 Members | 3,157 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,989 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 1258
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Shravan | last post by:
Hi, How can I bind DataRow array to ComboBox. I tried setting DataSource -> DataRow Array DisplayMember -> ColumnName But it was showing "System.Data.DataRow" for every item in the...
2
by: SoftWhiteDelgiht | last post by:
Help me. I am obviously stupid! :-) I am just starting out with VB.Net and am trying to do a simple master/detail form with a SqlServer backend. I have created a combo box which is to populate with...
0
by: Larry Serflaten | last post by:
I am not sure how many are aware of this sort of data binding, but as it is new to many (classic) VB developers I thought I would post this once just to let people know of its availablility. ...
0
by: JSantora | last post by:
Essentially, InsertAT is broken! For the past couple of hours, I've been getting this "Parameter name: '-2147483550' is not a valid value for 'index'." error. Apparently, its caused by having...
4
by: Jim Shaffer | last post by:
Perhaps I have the wrong construct, or misunderstand arrays in vb (2003).... I've loaded a two-dimensional array (168 by 28) into memory as AcctArray. {Dim AcctArray (500,28) as string...} The...
7
by: Nathan | last post by:
I'd like to use an enumeration as a datasource for a drop-down box. Is there a way to do this?
0
by: Roger Odermatt | last post by:
Hello I have binding a class to a DataGridView and this class have a property from another class and this i want binding to a DataGridViewComboBoxColumn. So when i change a item in the Combo and...
1
by: Monty M. | last post by:
Does anyone know how to perform two way data binding between a combo box and a listview. The listview is bound to a dataset table in code: Binding Bind = new Binding(); DataTable dt;...
3
by: Max | last post by:
Hello, I made a windows form with a combo box and 4 text boxes. All 5 objects should get their data from a data set which is populated in the form load method. The combo box has item ids. When...
0
by: Dawnyy | last post by:
I have a form which is bound to a dataset. I am filling the forms dataset on Form_Load event. On my form I have combo boxes which I am setting by running a stored procedure to return a datatable,...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...

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.