Auto Select Combobox item
Question posted by: Drum2001
(Guest)
on
July 13th, 2006 03:05 PM
I have a combobox that is populated from a button on the form.
One pushes this button and the following happens:
[Forms]![TimeEntry]![ItemName2] = Me.ItemName
So the combobox no shows whatever was in Me.ItemName. Here is my
question...
How do I autoselect this item? I know the following code will select
the first item in the list.
Me.ItemName2= Me.ItemName2.ItemData(0)
How do I select the "current" item on the list?
4
Answers Posted
Drum2001 wrote:
Quote:
Originally Posted by
I have a combobox that is populated from a button on the form.
>
One pushes this button and the following happens:
>
[Forms]![TimeEntry]![ItemName2] = Me.ItemName
>
So the combobox no shows whatever was in Me.ItemName. Here is my
question...
>
How do I autoselect this item? I know the following code will select
the first item in the list.
>
Me.ItemName2= Me.ItemName2.ItemData(0)
>
How do I select the "current" item on the list?
The question makes no sense. The "current" item is by definition the "selected"
item. At least it is as long as the value of a ComboBox actually exists as one
of the choices in the RowList.
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Right. It does show up in the list, but I have to "manually" re-select
it for the other cascading comboboxes to recognize it has been
selected. The combo box is unbound, if that makes a difference.
Rick Brandt wrote:
Quote:
Originally Posted by
Drum2001 wrote:
Quote:
Originally Posted by
I have a combobox that is populated from a button on the form.
One pushes this button and the following happens:
[Forms]![TimeEntry]![ItemName2] = Me.ItemName
So the combobox no shows whatever was in Me.ItemName. Here is my
question...
How do I autoselect this item? I know the following code will select
the first item in the list.
Me.ItemName2= Me.ItemName2.ItemData(0)
How do I select the "current" item on the list?
>
The question makes no sense. The "current" item is by definition the "selected"
item. At least it is as long as the value of a ComboBox actually exists as one
of the choices in the RowList.
>
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Drum2001 wrote:
Quote:
Originally Posted by
Right. It does show up in the list, but I have to "manually"
re-select it for the other cascading comboboxes to recognize it has
been selected. The combo box is unbound, if that makes a difference.
Correct. Events associated with changing a control's value do not fire if that
value is changed via code or macro. You need to call those events yourself.
Just add a line of code to the routine that sets the CombBox value that calls
the AfterUpdate event for that control.
Call ComboBoxName_AfterUpdate()
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Rick,
This works great!
On more question...
How could I call this function from a button push on a subform to a
"Call ComboBoxName_AfterUpdate()" on a main form?
Rick Brandt wrote:
Quote:
Originally Posted by
Drum2001 wrote:
Quote:
Originally Posted by
Right. It does show up in the list, but I have to "manually"
re-select it for the other cascading comboboxes to recognize it has
been selected. The combo box is unbound, if that makes a difference.
>
Correct. Events associated with changing a control's value do not fire if that
value is changed via code or macro. You need to call those events yourself.
Just add a line of code to the routine that sets the CombBox value that calls
the AfterUpdate event for that control.
>
Call ComboBoxName_AfterUpdate()
>
>
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
|
|
|
What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 196,984 network members.
Top Community Contributors
|