472,982 Members | 2,343 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,982 software developers and data experts.

Resetting combo boxes

Ant
Hi, (Winform VS2003)
I have a combo box bound to a typed data set. When the form loads, the
combo box is popluated using a method containing the simple code below:

------------------------
// Fill the datasets for the combo boxes
daDepartment.Fill(dsDepartment.Departments);

// Refresh the combo box
cboDepartment.Refresh();
------------------------------

This works fine, however, once the user has selected a, ummm, selection..
from the combo box, I want the combo box to reset the selection when they hit
the enter button. I use the same method above to do this, however their
selection is reatained & is shown as the current selection.
In other words If there is Selection A, B, C, D. On load the combo box is
set as A. Usr chooses C. After above method is run, I want combo again to
display A. This is not currently happening. C remains.

Hope somwone can shed some light on this seemingly simple problem.
Many thanks in advance.
Ant

Feb 13 '06 #1
5 2174
Use ComboBox.SelectedItem or ComboBox.SelectedIndex to reset the comboBox
selection.

e.g.
cboDepartment.SelectedItem = "My Dept";
or
cboDepartment.SelectedIndex = 0; // 0 = first listitem, -1 = no item is
selected

BTW, do you really need to rebind the data for every 'Enter' key?

"Ant" wrote:
Hi, (Winform VS2003)
I have a combo box bound to a typed data set. When the form loads, the
combo box is popluated using a method containing the simple code below:

------------------------
// Fill the datasets for the combo boxes
daDepartment.Fill(dsDepartment.Departments);

// Refresh the combo box
cboDepartment.Refresh();
------------------------------

This works fine, however, once the user has selected a, ummm, selection..
from the combo box, I want the combo box to reset the selection when they hit
the enter button. I use the same method above to do this, however their
selection is reatained & is shown as the current selection.
In other words If there is Selection A, B, C, D. On load the combo box is
set as A. Usr chooses C. After above method is run, I want combo again to
display A. This is not currently happening. C remains.

Hope somwone can shed some light on this seemingly simple problem.
Many thanks in advance.
Ant

Feb 13 '06 #2
Ant
Hi Tedmond,

Thanks for your advice. I'm using the index to refresh it now as suggested.
Cheers. As for binding with every entry; This was just an attempt at
refreshing the combo boxes. I'll be moving that out of the button now. Thanks
for your advice though.

Much appreciated.
Ant

"Tedmond" wrote:
Use ComboBox.SelectedItem or ComboBox.SelectedIndex to reset the comboBox
selection.

e.g.
cboDepartment.SelectedItem = "My Dept";
or
cboDepartment.SelectedIndex = 0; // 0 = first listitem, -1 = no item is
selected

BTW, do you really need to rebind the data for every 'Enter' key?

"Ant" wrote:
Hi, (Winform VS2003)
I have a combo box bound to a typed data set. When the form loads, the
combo box is popluated using a method containing the simple code below:

------------------------
// Fill the datasets for the combo boxes
daDepartment.Fill(dsDepartment.Departments);

// Refresh the combo box
cboDepartment.Refresh();
------------------------------

This works fine, however, once the user has selected a, ummm, selection..
from the combo box, I want the combo box to reset the selection when they hit
the enter button. I use the same method above to do this, however their
selection is reatained & is shown as the current selection.
In other words If there is Selection A, B, C, D. On load the combo box is
set as A. Usr chooses C. After above method is run, I want combo again to
display A. This is not currently happening. C remains.

Hope somwone can shed some light on this seemingly simple problem.
Many thanks in advance.
Ant

Feb 13 '06 #3
I have been trying to clear combobox settings in Access 2003 w/o success. I
was hoping what you stated here would work but it doesn't. It seens that
Access doesn't support .selectedItem or .SelectedIndex. Am I missing
somingthing?? As I'm really stuck.

I am assinging values to comboboxes either from a query row source or a mix
of user inputs which builds dynamic queries statements from the resultant
entries. The problem arrises when I select a numberic values for one query
and then a text value for the same CB w/o closing the form. I get a message
that the value entered is not valid. The only way I can get the CB to work
correctly again is to close the form and restart it.

Any advise would be greatly appreciated.
--
Mike

"Tedmond" wrote:
Use ComboBox.SelectedItem or ComboBox.SelectedIndex to reset the comboBox
selection.

e.g.
cboDepartment.SelectedItem = "My Dept";
or
cboDepartment.SelectedIndex = 0; // 0 = first listitem, -1 = no item is
selected

BTW, do you really need to rebind the data for every 'Enter' key?

"Ant" wrote:
Hi, (Winform VS2003)
I have a combo box bound to a typed data set. When the form loads, the
combo box is popluated using a method containing the simple code below:

------------------------
// Fill the datasets for the combo boxes
daDepartment.Fill(dsDepartment.Departments);

// Refresh the combo box
cboDepartment.Refresh();
------------------------------

This works fine, however, once the user has selected a, ummm, selection..
from the combo box, I want the combo box to reset the selection when they hit
the enter button. I use the same method above to do this, however their
selection is reatained & is shown as the current selection.
In other words If there is Selection A, B, C, D. On load the combo box is
set as A. Usr chooses C. After above method is run, I want combo again to
display A. This is not currently happening. C remains.

Hope somwone can shed some light on this seemingly simple problem.
Many thanks in advance.
Ant

Mar 15 '07 #4
Try setting combobox.SelectedIndex to -1.

This is a .Net programming newsgroup. If that answer doesn't work, try
posting your question to a Microsoft Access newsgroup.

Robin S.
-------------------------------
"Mike Samyn" <Mi*******@discussions.microsoft.comwrote in message
news:A5**********************************@microsof t.com...
>I have been trying to clear combobox settings in Access 2003 w/o success.
I
was hoping what you stated here would work but it doesn't. It seens
that
Access doesn't support .selectedItem or .SelectedIndex. Am I missing
somingthing?? As I'm really stuck.

I am assinging values to comboboxes either from a query row source or a
mix
of user inputs which builds dynamic queries statements from the resultant
entries. The problem arrises when I select a numberic values for one
query
and then a text value for the same CB w/o closing the form. I get a
message
that the value entered is not valid. The only way I can get the CB to
work
correctly again is to close the form and restart it.

Any advise would be greatly appreciated.
--
Mike

"Tedmond" wrote:
>Use ComboBox.SelectedItem or ComboBox.SelectedIndex to reset the
comboBox
selection.

e.g.
cboDepartment.SelectedItem = "My Dept";
or
cboDepartment.SelectedIndex = 0; // 0 = first listitem, -1 = no item is
selected

BTW, do you really need to rebind the data for every 'Enter' key?

"Ant" wrote:
Hi, (Winform VS2003)
I have a combo box bound to a typed data set. When the form loads,
the
combo box is popluated using a method containing the simple code
below:

------------------------
// Fill the datasets for the combo boxes
daDepartment.Fill(dsDepartment.Departments);

// Refresh the combo box
cboDepartment.Refresh();
------------------------------

This works fine, however, once the user has selected a, ummm,
selection..
from the combo box, I want the combo box to reset the selection when
they hit
the enter button. I use the same method above to do this, however
their
selection is reatained & is shown as the current selection.
In other words If there is Selection A, B, C, D. On load the combo box
is
set as A. Usr chooses C. After above method is run, I want combo again
to
display A. This is not currently happening. C remains.

Hope somwone can shed some light on this seemingly simple problem.
Many thanks in advance.
Ant

Mar 16 '07 #5
Robin,

No such property in Access. I will try thier group directly.

Thanks just the same.

--
Mike
"RobinS" wrote:
Try setting combobox.SelectedIndex to -1.

This is a .Net programming newsgroup. If that answer doesn't work, try
posting your question to a Microsoft Access newsgroup.

Robin S.
-------------------------------
"Mike Samyn" <Mi*******@discussions.microsoft.comwrote in message
news:A5**********************************@microsof t.com...
I have been trying to clear combobox settings in Access 2003 w/o success.
I
was hoping what you stated here would work but it doesn't. It seens
that
Access doesn't support .selectedItem or .SelectedIndex. Am I missing
somingthing?? As I'm really stuck.

I am assinging values to comboboxes either from a query row source or a
mix
of user inputs which builds dynamic queries statements from the resultant
entries. The problem arrises when I select a numberic values for one
query
and then a text value for the same CB w/o closing the form. I get a
message
that the value entered is not valid. The only way I can get the CB to
work
correctly again is to close the form and restart it.

Any advise would be greatly appreciated.
--
Mike

"Tedmond" wrote:
Use ComboBox.SelectedItem or ComboBox.SelectedIndex to reset the
comboBox
selection.

e.g.
cboDepartment.SelectedItem = "My Dept";
or
cboDepartment.SelectedIndex = 0; // 0 = first listitem, -1 = no item is
selected

BTW, do you really need to rebind the data for every 'Enter' key?

"Ant" wrote:

Hi, (Winform VS2003)
I have a combo box bound to a typed data set. When the form loads,
the
combo box is popluated using a method containing the simple code
below:

------------------------
// Fill the datasets for the combo boxes
daDepartment.Fill(dsDepartment.Departments);

// Refresh the combo box
cboDepartment.Refresh();
------------------------------

This works fine, however, once the user has selected a, ummm,
selection..
from the combo box, I want the combo box to reset the selection when
they hit
the enter button. I use the same method above to do this, however
their
selection is reatained & is shown as the current selection.
In other words If there is Selection A, B, C, D. On load the combo box
is
set as A. Usr chooses C. After above method is run, I want combo again
to
display A. This is not currently happening. C remains.

Hope somwone can shed some light on this seemingly simple problem.
Many thanks in advance.
Ant



Mar 16 '07 #6

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

Similar topics

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...
1
by: Anonymous | last post by:
Quick question - I have a form with with many fields on it. I have three combo boxes that are used as search engines (Last Name, City, State). For example, when I open the form, all three search...
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...
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...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
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...
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...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.