473,327 Members | 2,074 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,327 software developers and data experts.

combo boxes

I actually have a 3 part question.

1. How can I filter the items in combobox2 based on an item I select in
combobox1.

2. How can I make the start or initial value of the combobox blank or nothing?

3. When I select values in a combobox and close the form, then reopen the
form, the values are exactly the same as when I closed the form. How can I
make it refresh or start from the beginning?

Thanks,

Mike S.
Oct 10 '07 #1
5 1400
Mike,

Assuming that you use dataviews (you did not give any information about this
to us)

Set the result of combobox 1 as rowfilter in the dataview of combobox 2

Cor

Oct 10 '07 #2
Sorry for not giving enough info. Here is the code I use for displaying the
items in the combobox:

strSQL = "Select MachineType From MachType"
Using conn As New SqlClient.SqlConnection _
("Server=" & dbServer & ";Database=" & dbDatabase & ";User ID="
& dbUserName & ";Password=" & dbPassword)
Using com As SqlClient.SqlCommand = conn.CreateCommand
conn.Open()
ds = New DataSet
da = New SqlClient.SqlDataAdapter(strSQL, conn)
da.Fill(ds, "MachType")

Dim ac As New AutoCompleteStringCollection

For Each dr As DataRow In ds.Tables("MachType").Rows
ac.Add(dr.Item("MachineType").ToString)
cboMachType.Items.Add(dr.Item("MachineType").ToStr ing)
Next

cboMachType.AutoCompleteMode = AutoCompleteMode.Append
cboMachType.AutoCompleteSource =
AutoCompleteSource.CustomSource
cboMachType.AutoCompleteCustomSource = ac

End Using
End Using

The problem with this is when I select an item from the drop down, it
duplicates all the items so I have two of each item in the drop down. If I
close the form and reopen it and select the drop down, there will still be
duplicates of each item. And the next time there will be four of each item
and so on.

I tried using the same code for the second combobox and using the
"SelectedItem" as the search criteria in the "SQL Search" statement but I
coulnd't get it to work.

Let me know if you need more information.

Thanks,

Mike S.

"Cor Ligthert[MVP]" wrote:
Mike,

Assuming that you use dataviews (you did not give any information about this
to us)

Set the result of combobox 1 as rowfilter in the dataview of combobox 2

Cor
Oct 10 '07 #3
Just to clarify...The two datasources are separate dataviews (not joined),
each created by passing a datatable to the dataview's constructor. The
foreign key field of dataview2 provides the information necessary to make the
rowfilter for dataview2 work.

"MikeS" wrote:
I actually have a 3 part question.

1. How can I filter the items in combobox2 based on an item I select in
combobox1.

2. How can I make the start or initial value of the combobox blank or nothing?

3. When I select values in a combobox and close the form, then reopen the
form, the values are exactly the same as when I closed the form. How can I
make it refresh or start from the beginning?

Thanks,

Mike S.
Oct 10 '07 #4
Mike,

http://msdn2.microsoft.com/en-us/lib...x_members.aspx

Have a look at the properties:
DataSource,
DisplayMember
ValueMember

For the rest see the messages from Charlie

Cor

Oct 10 '07 #5
Also, each time you change the rowfilter, I think you have to rebind the
datasource for Combo2.

"MikeS" wrote:
I actually have a 3 part question.

1. How can I filter the items in combobox2 based on an item I select in
combobox1.

2. How can I make the start or initial value of the combobox blank or nothing?

3. When I select values in a combobox and close the form, then reopen the
form, the values are exactly the same as when I closed the form. How can I
make it refresh or start from the beginning?

Thanks,

Mike S.
Oct 11 '07 #6

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

Similar topics

3
by: vgrssrtrs | last post by:
<html> <head> <script language="JavaScript"> <!-- /* *** Multiple dynamic combo boxes *** by Mirko Elviro, 9 Mar 2005 *** ***Please do not remove this comment
1
by: FZ | last post by:
Hi Gang, I was wondering if a generous person might be able to walk me through what I believe is a pretty simple task. I actually have significant Access experience, but I haven't done it in...
0
by: Krisa | last post by:
Hello all, I just discovered something (stop me if you've heard this before....) that was causing me a significant performance hit when opening a form with subforms. To speed up loading the...
0
by: Tom | last post by:
I have some very strange issues with combo boxes on a tab control. Here's the scenario: I have a Windows Forms form that has a tab control on it, with two (2) tabs. Tab 2 happens to have a number...
5
by: jjyconsulting | last post by:
Newbie needing some help. I have a tblParticipants. The fields include gender, education_level, income, occupation etc., I'm trying to create a form where a user can run a query from the form and...
4
by: Dave | last post by:
I wasn't sure how to search for previous posts about this, it felt real specific. Ok so here's the database & problem: I have 4 combo boxes: cboServer, cboPolicy, cboDB, and cboApplication. ...
6
by: Dave | last post by:
I want to put the information that the user selects in my combo boxes into a subform that lies on the same form as the combo boxes. Thanks for your help already, Dave
1
by: Dave | last post by:
Hello all, First I'd like to apologize...This post was meant to be put in my previous post, but I tried many times without success to reply within my previous post. Now here goes... I have a...
2
by: Dave | last post by:
I have 3 tables of information feeding into 4 combo boxes on my main form (DR Form). I have as many list boxes (acting as text boxes) as there are fields in each one of the 3 tables. Once...
2
by: someshbakliwal | last post by:
Hi, I have created some autopopulating combo boxes on my HTML page (script- Javascript). so these combo boxes are autopopulated with choices made in previous combo boxes. The problem I am facing is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.