473,795 Members | 3,295 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how can i get a query index from a combobox selection?

jen
i have select query that returns multiple records and populates a
combobox/pulldown.

once a selection from the pulldown is selected, i need to reference two
or three fileds from the previous query related to that selection.

as usual, i'm probably making this harder than it needs to be.

any help is newbiously appreciated.

thanks...

--
hail the forest daemon!

Oct 22 '06 #1
2 2522

jen wrote:
i have select query that returns multiple records and populates a
combobox/pulldown.

once a selection from the pulldown is selected, i need to reference two
or three fileds from the previous query related to that selection.
What you're looking for is what's unfortunately missing from the
ComboBox in the .NET framework: a Tag field on a combo box item that
allows you to connect it back to a business object or data row.

There are several ways to do this.

The simplest is to display the combo box items in the same order that
they are in the DataRowCollecti on, and use the combo box's
SelectedIndex to find the data row. So, if the user chooses an item
with index 5, you go and get the data row at index 5 (the sixth data
row) and that's the one that was chosen.

If you need a particular ordering for the combo box items, put a
DataView on top of the DataTable, and then populate the combo box from
the DataView.

Another way to do it is to put your data in objects and add them to the
combo box using its .Items.Add() method. You then set the ComboBox's
DisplayMember property to the name of the object property (as a string)
that the combo box should display to the user. So, for example, if your
data rows represent customers, you might say

comboBox1.Displ ayMember = "Name";

to display the .Name property of the customer objects as the combo box
item text.

Now when the user selects an item in the combo box, you can use
SelectedItem to get the object they selected.

Oct 23 '06 #2
jen

Bruce Wood wrote:
jen wrote:
i have select query that returns multiple records and populates a
combobox/pulldown.

once a selection from the pulldown is selected, i need to reference two
or three fileds from the previous query related to that selection.

What you're looking for is what's unfortunately missing from the
ComboBox in the .NET framework: a Tag field on a combo box item that
allows you to connect it back to a business object or data row.

There are several ways to do this.

The simplest is to display the combo box items in the same order that
they are in the DataRowCollecti on, and use the combo box's
SelectedIndex to find the data row. So, if the user chooses an item
with index 5, you go and get the data row at index 5 (the sixth data
row) and that's the one that was chosen.

If you need a particular ordering for the combo box items, put a
DataView on top of the DataTable, and then populate the combo box from
the DataView.

Another way to do it is to put your data in objects and add them to the
combo box using its .Items.Add() method. You then set the ComboBox's
DisplayMember property to the name of the object property (as a string)
that the combo box should display to the user. So, for example, if your
data rows represent customers, you might say

comboBox1.Displ ayMember = "Name";

to display the .Name property of the customer objects as the combo box
item text.

Now when the user selects an item in the combo box, you can use
SelectedItem to get the object they selected.
hey bruce thanks for the reply. sorry i didn't get back sooner. i
figured out a way to index it the way i wanted. thanks again!

--
jen

Nov 6 '06 #3

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

Similar topics

3
7496
by: Wayne Wengert | last post by:
I am trying to populate a combobox with a lisy of items. I want the 1st item to be "Make a Selection" and the following items will be names from a table in my DB (See code below). When I run the project, the combox box initially displays an empty selection. When I click on the drop down arrow I see the "Make a Selection" followed by the other choices. How can I move everything up so that the "Make a Selection" is the default value in...
3
5225
by: Paul Mateer | last post by:
Hi, I have been running some queries against a table in a my database and have noted an odd (at least it seems odd to me) performance issue. The table has approximately 5 million rows and includes the following columns: DocID (INTEGER, PRIMARY KEY, CLUSTERED) IsRecord (INTEGER, NONCLUSTERED)
1
1972
by: Steve | last post by:
I have a continuous form with several unbound comboboxes in the form header. The comboboxes are used to provide criteria for the SQL of the form. The code behind the form looks like: Public Sub FormSQL() Dim SQLStr As String SQLStr = < Code to build SQL String based on selection in comboboxes> SQLStr = SQLStr & ";" Me.RecordSource = SQLStr End Sub
3
4988
by: Steve | last post by:
Form FrmRestock's recordsource is QryFrmRestock. The TransactionDate field's criteria is set ats: Forms!FrmRestock!LastXDays. LastXDays on the form is a combobox where the selections are 30, 60 and 90. The default is set at 30. Question1: When the form opens, there are no records displayed although there are many records that fit the criteria of 30. If I put a button on the form to do a requery and press the button, all the records...
1
5840
by: CCC | last post by:
Our company have used Excel to filter out documents base on date, from_company, type_of_document, country to generate a list of where the documents physical location is. The number of records have grown to 8000 and I think it is time to use Access 2000 to handle those records. I am completely new to Access. So far I managed to make the selection in combobox1 narrow down the list in combobox2, and combobox2 narrow down combobox3 and so...
3
5612
by: Ray Holtz | last post by:
Access 2003 (2000 file format) question: When I run a form, it opens with only a combo box and a button to execute a query based on the criteria tha is selected in the combobox. Then I need Access to open a report using that query. Can someone give me some pointers on how to do this, or please point me in the direction I need to look for this answer? Thanks,
3
6732
by: Magnus | last post by:
Im using a set combobox (ComboBox1) to provide a selection of records from a database table. I have a typed dataset (DataSet1) that contains the typed datatable (DataTable1) that the combobox is bound to. The datatable in the dataset is filled using the typed tableadapter (TableAdapter1). DataTable consists of the typical primary key and value fields. Here is the designer generated code for ComboBox1: this.ComboBox1.DataSource =...
18
13387
by: WU10 | last post by:
Built a form based on a select query with a combo box (3 choices) in the form header which will supply a value to the query. In the query's criteria I added the following expression - !! and this works like a charm. However one of my users wanted to see all of the values before choosing one of the three selections. I added the choice "All" to my combo dropdown list and tried the following iif statement as the criteria:...
1
8066
by: The.Daryl.Lu | last post by:
Hi, two parts to my problem if someone can help address either one or both: 1. I want to SELECT everything in the table if it matches the criteria when the query button is pressed (this is just a commandbutton on my form). The biggest problem I'm having is that I can't (don't know how) populate a combobox on static items such as "True, False, Any." The Any field, would be selected by the user to find all records where that fields is...
0
9672
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10436
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10213
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
10163
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
9040
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...
0
6780
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
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3722
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.