473,395 Members | 1,496 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Lookup Field Values Based on Combobox Change

Hi,
I'm trying to populate textbox values upon a change in a combobox
selection. I'm using the Publishers table in the Pubs sample database
as a simplified example. Here is the code:

Private Sub cboPubID_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
cboPubID.SelectedIndexChanged
Dim PubsDS As New PUBSDataSet()
Dim PubsTA As New
PUBSDataSetTableAdapters.publishersTableAdapter

PubsTA.Fill(PubsDS.publishers)

txtPubName.Text =
PubsDS.Tables("publishers").Rows(cboPubID.Text)(1) .ToString
txtCity.Text = PubsDS.Tables("publishers").Rows(cboPubID.Text)
(2).ToString
End Sub
The last two lines are where I am trying to lookup the field values in
columns 1 and 2 based on the row as determined from the combobox
selection. These lines aren't working. I've tried searching this
board for the answer, but no luck.

Anybody know how to do this?
Thanks,
Randy

Apr 6 '07 #1
2 1772
Here's another attempt, but it comes back empty. Why?

txtCity.Text =
PubsDS.Tables("publishers").Rows(cboPubID.Selected Index).Item(1).ToString

Please help. I'm stuck!!! Robin, my savior? Cor (I do like you, you
know)? ;^)

Randy

Apr 7 '07 #2
If you load your table and bind your combobox using my code in my response
to your other post, each entry in the combobox is a datarow, and you should
be able to pull the data like this:

Dim drv As DataRowView = CType(TableComboBox.SelectedItem, DataRowView)
Debug.Print("First Column = {0}, Second column = {1}", _
CType(drv("PubID"), Integer), drv("PublisherName").ToString)

Each item in the combobox is a datarow.

If you bind your combobox to a List(Of T), each item will be an instance of
T.

Good luck.
Robin S.
-----------------------
"Randy" <sp***********@gmail.comwrote in message
news:11**********************@y66g2000hsf.googlegr oups.com...
Here's another attempt, but it comes back empty. Why?

txtCity.Text =
PubsDS.Tables("publishers").Rows(cboPubID.Selected Index).Item(1).ToString

Please help. I'm stuck!!! Robin, my savior? Cor (I do like you, you
know)? ;^)

Randy

Apr 7 '07 #3

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

Similar topics

3
by: my-wings | last post by:
I've been reading about how evil Lookup fields in tables are, but I've got to be missing something really basic. I know this subject has been covered before, because I've just spent an hour or two...
4
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...
3
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...
14
by: Mark | last post by:
I have a table with a field that uses a combobox to populate values. The Lookup tab within table design mode is the following: Display Control Combo Box Row Source Type ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...

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.