By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,671 Members | 1,278 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,671 IT Pros & Developers. It's quick & easy.

Auto Select Combobox item

P: n/a
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?

Jul 13 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Drum2001 wrote:
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
Jul 13 '06 #2

P: n/a
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:
Drum2001 wrote:
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
Jul 13 '06 #3

P: n/a
Drum2001 wrote:
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
Jul 13 '06 #4

P: n/a
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:
Drum2001 wrote:
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
Jul 13 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.