473,842 Members | 1,570 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bound Combo Box, Lookup Table?

I am used to VB6 but need to develop something in .Net.

I need to create several bound combo-boxes which will use lookup tables to
get their values.

I created a form using the dataform wizard. As part of the setup, I
specified a new dataset, which included the data & lookup tables. I also
specified the relationships when required.

I then added a combo box control to my form, following the instructions from
dynamic help:

I set the datasource for the control to the lookup table.
I set the DisplayMember to the required text column from my lookup table.
I set the ValueMember to the required ID column from my lookup table.

Under DataBindings.Se lectedValue I specified my base table, & relevant
column.
This all appears to work, however the problem appears to arise with null
values.

When the form is loaded & the data is fetched, if the source column for the
lookup is null, the combo displays the first entry in the list of the combo
control.
If I select a value, & select the update button (the form was created with
teh standard settings in the wizard), the correct value is inserted into the
underlying table. However, when I navigate to the next record, if it is
null, again the first value in the list is displayed.
Finally, if I attempt to remove a value from the form (i.e. make it null) &
then update, the update will succeed. However the combo will then update &
show the first entry in the list.

I had a look at the code executing with a watch placed on the SelectedValue
property of the combo. It is always correct until, as part of the
UpdateDataSet sub, the DataSet.Merge method is called. At this point the
first value is displayed in the combo.

Any suggestions for a solution?
Cheers,
James
Nov 20 '05 #1
1 3375
I have now replicated this with from the Combo box demonstration on msdn
(http://msdn.microsoft.com/library/en...lkcreatinglook
uptableondata-boundwindowsfor m.asp?frame=tru e&_r=1)
The file can be found here:
http://www.j.goodman.dsl.pipex.com/f...bleExample.zip

This example also requires the Northwind sample db. If you set the value of
CustomerID to Null for a record, & then load the form it demonstrates this
phenomenon. If the modified record is loaded first, the combo will be blank.
However, if the user navigates to the next (or previous) record, & then back
to the record, the combo will show the first entry in the list.

"James" <j_*********@ya hoo.co.uk> wrote in message
news:82******** *************** *@posting.googl e.com...
I am used to VB6 but need to develop something in .Net.

I need to create several bound combo-boxes which will use lookup tables to
get their values.

I created a form using the dataform wizard. As part of the setup, I
specified a new dataset, which included the data & lookup tables. I also
specified the relationships when required.

I then added a combo box control to my form, following the instructions from dynamic help:

I set the datasource for the control to the lookup table.
I set the DisplayMember to the required text column from my lookup table.
I set the ValueMember to the required ID column from my lookup table.

Under DataBindings.Se lectedValue I specified my base table, & relevant
column.
This all appears to work, however the problem appears to arise with null
values.

When the form is loaded & the data is fetched, if the source column for the lookup is null, the combo displays the first entry in the list of the combo control.
If I select a value, & select the update button (the form was created with
teh standard settings in the wizard), the correct value is inserted into the underlying table. However, when I navigate to the next record, if it is
null, again the first value in the list is displayed.
Finally, if I attempt to remove a value from the form (i.e. make it null) & then update, the update will succeed. However the combo will then update &
show the first entry in the list.

I had a look at the code executing with a watch placed on the SelectedValue property of the combo. It is always correct until, as part of the
UpdateDataSet sub, the DataSet.Merge method is called. At this point the
first value is displayed in the combo.

Any suggestions for a solution?
Cheers,
James

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3458
by: Phil | last post by:
My form uses a dataset containing two tables, a base table (Contact) and a lookup table (Insurer). My combobox is bound as follows: DataSource = datasetContact DisplayMember = Insurer.InsurerName ValueMember = Insurer.InsurerId DataBindings.SelectedValue = Contact.InsurerId It generally works fine. I am able to navigate records and
5
4667
by: Aaron Ackerman | last post by:
I have a bound combobox the appears on a cell within the column of my bound grid when the user clicks on a cell n(In my vb.net WinForm app). I am trying to allow the adding of an item to that bound combo by allowing the user to dynamically type in the new value directly in the combo box whcih in turn updates the lookup table and then when they have finished leaves that particular cell on the grid with the correct value. Seems...
0
927
by: James | last post by:
I have a bound combo using a lookup table which is behaving as expected with the exception of the first record. In the list of rows for my combo, the first is '.'. This is because of another issue I had with a bound combo box, whereby nulls were populated with values (A known bug with MS). If my first record has a value other than period, when the user first loads the form it is displayed as a period, & subsequently my dataset is...
4
4624
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box bound to a table as a lookup, drawing values from another table to populate the available selections. This all worked fine in VB6. I have distilled the problem down to a simple form drawing data from the Northwind database for a representative...
1
4875
by: Bill | last post by:
Problem: Combo box data disappears from view when a requery is done See "Background" below for details on tables, forms & controls On a form, I want to use the setting of bound combo box C1 to limit what is displayed in bound combo box C2. When I display Tbl-A records on a continuous form, and navigate away from record 1 to record 2, the previously entered data displayed in C2 for record 1 disappears from
9
32631
by: Vmusic | last post by:
Hi, I'm using MS Access 2002. I have a form with a combo box built from a query that returns one column, and that one column is the bound column. How do you use VBA to programmatically change which row in the combo box is selected?? I looked at the forum and the answers aren't very clear. Of course the MS Access help file is worthless.
0
2000
by: northshore | last post by:
Hello, I am creating a windows application database. I have a primary table 'Individuals' and a lookup table 'Prefixes.' In the Individuals table, I have a column 'PrefixID' that references values of prefixes from the Prefix table based on the PrefixID in the Prefix table. When I load a windows application form, I can display and update data from the primary table. This includes the prefixID value. If I display a combo box with...
3
3554
by: Jimmy | last post by:
I'm not sure the subject line is a very clear description of my problem so... I have two relevant tables for this issue... the lookup table tblLookupItems with three fields . The control source for my form tblExpenses. In this table there are three relevant fields . On the form the field is set up as a combobox to get
3
2398
by: Jay Ruyle | last post by:
I'm trying to figure out a way to list several items in a listbox and let the user select any number of items in the listbox. I have tried to code in the items as bitwise items but all it stores in the database is the top item in the listbox. How can I get the listbox to add all the bit values to be stored and also come out properly when viewed later? Example:
0
10614
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10674
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10317
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9454
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7859
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7040
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5886
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4090
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3146
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.