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

Is this a bug in VB?

P: n/a
I am writing some VB code in a combo box's 'On Click' event on a form. It
would appear the event fires when a selection is clicked on from the
available drop down list. This is about what I would expect to happen and
so my code runs just fine.

However, if any editing is done in the box (i.e. don't select from the list
and just type my own entry, or perhaps make changes to what was selected
from the drop down list) and then I click on some other control on the form,
then the 'On Click' event fires for the combo box? (It looks more like a
'Lost Focus' event to me!).

Is this some bug in VB or am I misunderstanding the event? I've gone to
Microsoft's web for Office updates and it says everything's up to date.

Thanks,

Gord
Aug 10 '08 #1
Share this Question
Share on Google+
21 Replies


P: n/a
That's a new one on me Gord. Did you check to make sure there are no other
events with code behind them? Sounds like an LostFocus event to me also.

Bonnie
http://www.dataplus-svc.com

Gord wrote:
>I am writing some VB code in a combo box's 'On Click' event on a form. It
would appear the event fires when a selection is clicked on from the
available drop down list. This is about what I would expect to happen and
so my code runs just fine.

However, if any editing is done in the box (i.e. don't select from the list
and just type my own entry, or perhaps make changes to what was selected
from the drop down list) and then I click on some other control on the form,
then the 'On Click' event fires for the combo box? (It looks more like a
'Lost Focus' event to me!).

Is this some bug in VB or am I misunderstanding the event? I've gone to
Microsoft's web for Office updates and it says everything's up to date.

Thanks,

Gord
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200808/1

Aug 10 '08 #2

P: n/a
Gord wrote:
I am writing some VB code in a combo box's 'On Click' event on a form. It
would appear the event fires when a selection is clicked on from the
available drop down list. This is about what I would expect to happen and
so my code runs just fine.

However, if any editing is done in the box (i.e. don't select from the list
and just type my own entry, or perhaps make changes to what was selected
from the drop down list) and then I click on some other control on the form,
then the 'On Click' event fires for the combo box? (It looks more like a
'Lost Focus' event to me!).

Is this some bug in VB or am I misunderstanding the event? I've gone to
Microsoft's web for Office updates and it says everything's up to date.

Thanks,

Gord

I created a new form; A97. 2 Controls; Combo with with values; 1,2,3,4
and a command button to close the form.

If I tab between the two controls and change the value by entering
1,2,3,4 it executes the click or after update event depending on the
value entered. Same with clicking on the dropdown values and selecting.
Private Sub Combo0_AfterUpdate()
If Me.Combo0 < 3 Then MsgBox "After Less than 3"
End Sub
Private Sub Combo0_Click()
If Me.Combo0 2 Then MsgBox "Click Greater than 2"
End Sub

I changed the code to
Private Sub Combo0_AfterUpdate()
If Me.Combo0 < 3 Then
MsgBox "After Less than 3"
Else
MsgBox "After Greater than 2"
End If
End Sub
Private Sub Combo0_Click()
If Me.Combo0 2 Then
MsgBox "Click Greater than 2"
Else
MsgBox "Click Less than 3"
End If
End Sub

It always executed the AfterUpdate then the Click event; by entering the
values and tabbing or selecting the values from the dropdown via the mouse.

Here's what A97 help says
For a control, this event occurs when the user:

Clicks a control with the left mouse button. Clicking a control with
the right or middle mouse button does not trigger this event.
Clicks a control containing hyperlink data with the left mouse button.
Clicking a control with the right or middle mouse button does not
trigger this event. When the user moves the mouse pointer over a control
containing hyperlink data, the mouse pointer changes to a "hand" icon.
When the user clicks the mouse button, the hyperlink is activated, and
then the Click event occurs.

Selects an item in a combo box or list box, either by pressing the
arrow keys and then pressing the ENTER key or by clicking the mouse button.
Presses SPACEBAR when a command button, check box, option button, or
toggle button has the focus.
Presses the ENTER key on a form that has a command button whose
Default property is set to Yes.

Presses the ESC key on a form that has a command button whose Cancel
property is set to Yes.
Presses a control's access key. For example, if a command button's
Caption property is set to &Go, pressing ALT+G triggers the event.

When I change the value and tab...I don't see that listed as an action
that would activate the OnClick event.

Is it a bug? I'll let the experts decide.
Aug 10 '08 #3

P: n/a
There's no other code. I simplified everything to eliminate variables.
Just put a combo box and some other control on a form (combo doesn't even
need source for a list). Put a 'msgbox "This combo executed its click
event"' in the click event of the combo. Now run the form and type
something into the combo, then click on the other control. You'll see what
I mean.

Thanks,

Gord

By the way, I'm using Access 2007.

"bhicks11 via AccessMonster.com" <u44327@uwewrote in message
news:88702e8eec2bc@uwe...
That's a new one on me Gord. Did you check to make sure there are no
other
events with code behind them? Sounds like an LostFocus event to me also.

Bonnie
http://www.dataplus-svc.com

Gord wrote:
>>I am writing some VB code in a combo box's 'On Click' event on a form. It
would appear the event fires when a selection is clicked on from the
available drop down list. This is about what I would expect to happen and
so my code runs just fine.

However, if any editing is done in the box (i.e. don't select from the
list
and just type my own entry, or perhaps make changes to what was selected
from the drop down list) and then I click on some other control on the
form,
then the 'On Click' event fires for the combo box? (It looks more like a
'Lost Focus' event to me!).

Is this some bug in VB or am I misunderstanding the event? I've gone to
Microsoft's web for Office updates and it says everything's up to date.

Thanks,

Gord

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200808/1

Aug 10 '08 #4

P: n/a
I'm no expert but I call it a bug.

I tried other events trying to find a way to write around the problem but
haven't figured it out yet. All the events I tried occurred after the click
event. I never tried the 'after update' event though and it does seem to
occur before the 'on click' event. This may be something that I can use as
a work around.

Thanks,

Gord

I'm using Access 2007 by the way.

"Salad" <oi*@vinegar.comwrote in message
news:z9******************************@earthlink.co m...
Gord wrote:
>I am writing some VB code in a combo box's 'On Click' event on a form.
It would appear the event fires when a selection is clicked on from the
available drop down list. This is about what I would expect to happen
and so my code runs just fine.

However, if any editing is done in the box (i.e. don't select from the
list and just type my own entry, or perhaps make changes to what was
selected from the drop down list) and then I click on some other control
on the form, then the 'On Click' event fires for the combo box? (It
looks more like a 'Lost Focus' event to me!).

Is this some bug in VB or am I misunderstanding the event? I've gone to
Microsoft's web for Office updates and it says everything's up to date.

Thanks,

Gord
I created a new form; A97. 2 Controls; Combo with with values; 1,2,3,4
and a command button to close the form.

If I tab between the two controls and change the value by entering 1,2,3,4
it executes the click or after update event depending on the value
entered. Same with clicking on the dropdown values and selecting.
Private Sub Combo0_AfterUpdate()
If Me.Combo0 < 3 Then MsgBox "After Less than 3"
End Sub
Private Sub Combo0_Click()
If Me.Combo0 2 Then MsgBox "Click Greater than 2"
End Sub

I changed the code to
Private Sub Combo0_AfterUpdate()
If Me.Combo0 < 3 Then
MsgBox "After Less than 3"
Else
MsgBox "After Greater than 2"
End If
End Sub
Private Sub Combo0_Click()
If Me.Combo0 2 Then
MsgBox "Click Greater than 2"
Else
MsgBox "Click Less than 3"
End If
End Sub

It always executed the AfterUpdate then the Click event; by entering the
values and tabbing or selecting the values from the dropdown via the
mouse.

Here's what A97 help says
For a control, this event occurs when the user:

Clicks a control with the left mouse button. Clicking a control with the
right or middle mouse button does not trigger this event.
Clicks a control containing hyperlink data with the left mouse button.
Clicking a control with the right or middle mouse button does not trigger
this event. When the user moves the mouse pointer over a control
containing hyperlink data, the mouse pointer changes to a "hand" icon.
When the user clicks the mouse button, the hyperlink is activated, and
then the Click event occurs.

Selects an item in a combo box or list box, either by pressing the arrow
keys and then pressing the ENTER key or by clicking the mouse button.
Presses SPACEBAR when a command button, check box, option button, or
toggle button has the focus.
Presses the ENTER key on a form that has a command button whose Default
property is set to Yes.

Presses the ESC key on a form that has a command button whose Cancel
property is set to Yes.
Presses a control's access key. For example, if a command button's
Caption property is set to &Go, pressing ALT+G triggers the event.

When I change the value and tab...I don't see that listed as an action
that would activate the OnClick event.

Is it a bug? I'll let the experts decide.

Aug 10 '08 #5

P: n/a
This is standard behavior, not a bug, going back to v2000 that I personally
know of, and apparently, from Salad's post, back to v97. When you type a
value into a combobox, or edit an item in a combobox, then move to another
control, you are making a selection from the combobox, just the same as if
you "clicked" on an item, which is how Access interprets it..

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200808/1

Aug 10 '08 #6

P: n/a
Thanks Linq - good to know.

Bonnie
http://www.dataplus-svc.com

Linq Adams wrote:
>This is standard behavior, not a bug, going back to v2000 that I personally
know of, and apparently, from Salad's post, back to v97. When you type a
value into a combobox, or edit an item in a combobox, then move to another
control, you are making a selection from the combobox, just the same as if
you "clicked" on an item, which is how Access interprets it..
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200808/1

Aug 10 '08 #7

P: n/a
Thanks Linq.

If microsoft makes this the standard behaviour then I guess I'm stuck with
it but it's not my idea of an 'On Click' event. It would appear there's no
way to tell for certain if the user has just made a selection (clicked) from
the drop down list, which to my mind is pretty important.

Anyway, I'll continue trying to skin this cat with boolean variables/other
events etc.

Once again, thanks.

Gord

"Linq Adams via AccessMonster.com" <u28780@uwewrote in message
news:8876286c8b538@uwe...
This is standard behavior, not a bug, going back to v2000 that I
personally
know of, and apparently, from Salad's post, back to v97. When you type a
value into a combobox, or edit an item in a combobox, then move to another
control, you are making a selection from the combobox, just the same as if
you "clicked" on an item, which is how Access interprets it..

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200808/1

Aug 10 '08 #8

P: n/a
"Gord" <x1******@telus.netwrote in
news:XnEnk.5108$%b7.2187@edtnps82:
Thanks Linq.

If microsoft makes this the standard behaviour then I guess I'm
stuck with it but it's not my idea of an 'On Click' event. It
would appear there's no way to tell for certain if the user has
just made a selection (clicked) from the drop down list, which to
my mind is pretty important.

Anyway, I'll continue trying to skin this cat with boolean
variables/other events etc.

Once again, thanks.

Gord
You can tell that the user has made a selection because the
After_Update event fires when the user clicks to make as selection.
I cannot find a reason to differentiate how the update was
triggered, eg, Enter key, paste from clipboard or click


>
"Linq Adams via AccessMonster.com" <u28780@uwewrote in message
news:8876286c8b538@uwe...
>This is standard behavior, not a bug, going back to v2000 that I
personally
know of, and apparently, from Salad's post, back to v97. When you
type a value into a combobox, or edit an item in a combobox, then
move to another control, you are making a selection from the
combobox, just the same as if you "clicked" on an item, which is
how Access interprets it..

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For.../databases-ms-
access/2
>00808/1




--
Bob Quintal

PA is y I've altered my email address.
** Posted from http://www.teranews.com **
Aug 10 '08 #9

P: n/a
Yes Bob, but I can certainly see his point. Why have a different event if it
isn't really OnClick only - just use the OnChange or LostFocus etc.

Bonnie
http://www.dataplus-svc.com

Bob Quintal wrote:
>Thanks Linq.
[quoted text clipped - 10 lines]
>>
Gord

You can tell that the user has made a selection because the
After_Update event fires when the user clicks to make as selection.
I cannot find a reason to differentiate how the update was
triggered, eg, Enter key, paste from clipboard or click
>>This is standard behavior, not a bug, going back to v2000 that I
personally
[quoted text clipped - 3 lines]
>>combobox, just the same as if you "clicked" on an item, which is
how Access interprets it..
--
Message posted via http://www.accessmonster.com

Aug 10 '08 #10

P: n/a

The 'After Update' event fires when going to another control as well, not
just clicking a selection from the drop down. Unless I misunderstand
somehow, it's impossible to tell when a selection has been chosen from the
list.
"Bob Quintal" <rq******@sPAmpatico.cawrote in message
news:Xn**********************@66.175.223.2...
"Gord" <x1******@telus.netwrote in
news:XnEnk.5108$%b7.2187@edtnps82:
>Thanks Linq.

If microsoft makes this the standard behaviour then I guess I'm
stuck with it but it's not my idea of an 'On Click' event. It
would appear there's no way to tell for certain if the user has
just made a selection (clicked) from the drop down list, which to
my mind is pretty important.

Anyway, I'll continue trying to skin this cat with boolean
variables/other events etc.

Once again, thanks.

Gord

You can tell that the user has made a selection because the
After_Update event fires when the user clicks to make as selection.
I cannot find a reason to differentiate how the update was
triggered, eg, Enter key, paste from clipboard or click


>>
"Linq Adams via AccessMonster.com" <u28780@uwewrote in message
news:8876286c8b538@uwe...
>>This is standard behavior, not a bug, going back to v2000 that I
personally
know of, and apparently, from Salad's post, back to v97. When you
type a value into a combobox, or edit an item in a combobox, then
move to another control, you are making a selection from the
combobox, just the same as if you "clicked" on an item, which is
how Access interprets it..

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For.../databases-ms-
access/2
>>00808/1



--
Bob Quintal

PA is y I've altered my email address.
** Posted from http://www.teranews.com **

Aug 10 '08 #11

P: n/a
"Gord" <x1******@telus.netwrote in
news:mbJnk.6310$nu6.5122@edtnps83:
>
The 'After Update' event fires when going to another control as
well, not just clicking a selection from the drop down. Unless I
misunderstand somehow, it's impossible to tell when a selection
has been chosen from the list.
The update occurs, and triggers several events, when leaving the
control, provided that the user actually changed the contents of the
listbox. And one can choose from the list without clicking, using
key presses..

The Click event is necessary for some types of controls, such as
buttons. Although text, combo and list boxes have the click event, I
don't see much use of it being there, sort of like the appendix in
our intestines, Anything done via a text, combo or listbox click
event can be done with other events.

>
"Bob Quintal" <rq******@sPAmpatico.cawrote in message
news:Xn**********************@66.175.223.2...
>"Gord" <x1******@telus.netwrote in
news:XnEnk.5108$%b7.2187@edtnps82:
>>Thanks Linq.

If microsoft makes this the standard behaviour then I guess I'm
stuck with it but it's not my idea of an 'On Click' event. It
would appear there's no way to tell for certain if the user has
just made a selection (clicked) from the drop down list, which
to my mind is pretty important.

Anyway, I'll continue trying to skin this cat with boolean
variables/other events etc.

Once again, thanks.

Gord

You can tell that the user has made a selection because the
After_Update event fires when the user clicks to make as
selection. I cannot find a reason to differentiate how the update
was triggered, eg, Enter key, paste from clipboard or click


>>>
"Linq Adams via AccessMonster.com" <u28780@uwewrote in message
news:8876286c8b538@uwe...
This is standard behavior, not a bug, going back to v2000 that
I personally
know of, and apparently, from Salad's post, back to v97. When
you type a value into a combobox, or edit an item in a
combobox, then move to another control, you are making a
selection from the combobox, just the same as if you "clicked"
on an item, which is how Access interprets it..

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For.../databases-ms-
access/2
>>>00808/1


--
Bob Quintal

PA is y I've altered my email address.
** Posted from http://www.teranews.com **




--
Bob Quintal

PA is y I've altered my email address.
** Posted from http://www.teranews.com **
Aug 11 '08 #12

P: n/a
"Gord" <x1******@telus.netwrote in
news:mbJnk.6310$nu6.5122@edtnps83:
>
The 'After Update' event fires when going to another control as
well, not just clicking a selection from the drop down. Unless I
misunderstand somehow, it's impossible to tell when a selection
has been chosen from the list.
There is the On Not In List event, which is used in conjunction with
the Limit to List property, so that action can be taken to update
the source of the list.

If you set the Limit to list to No, then you could simulate it with
a little code in the After update event to compare the current value
with all the values in the list. Then you will know if the selection
came from the list or is an unlisted value.

>
"Bob Quintal" <rq******@sPAmpatico.cawrote in message
news:Xn**********************@66.175.223.2...
>"Gord" <x1******@telus.netwrote in
news:XnEnk.5108$%b7.2187@edtnps82:
>>Thanks Linq.

If microsoft makes this the standard behaviour then I guess I'm
stuck with it but it's not my idea of an 'On Click' event. It
would appear there's no way to tell for certain if the user has
just made a selection (clicked) from the drop down list, which
to my mind is pretty important.

Anyway, I'll continue trying to skin this cat with boolean
variables/other events etc.

Once again, thanks.

Gord

You can tell that the user has made a selection because the
After_Update event fires when the user clicks to make as
selection. I cannot find a reason to differentiate how the update
was triggered, eg, Enter key, paste from clipboard or click


>>>
"Linq Adams via AccessMonster.com" <u28780@uwewrote in message
news:8876286c8b538@uwe...
This is standard behavior, not a bug, going back to v2000 that
I personally
know of, and apparently, from Salad's post, back to v97. When
you type a value into a combobox, or edit an item in a
combobox, then move to another control, you are making a
selection from the combobox, just the same as if you "clicked"
on an item, which is how Access interprets it..

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For.../databases-ms-
access/2
>>>00808/1


--
Bob Quintal

PA is y I've altered my email address.
** Posted from http://www.teranews.com **



--
Bob Quintal

PA is y I've altered my email address.
** Posted from http://www.teranews.com **
Aug 11 '08 #13

P: n/a
"Gord" <x1******@telus.netwrote in
news:mbJnk.6310$nu6.5122@edtnps83:
The 'After Update' event fires when going to another control as
well, not just clicking a selection from the drop down. Unless I
misunderstand somehow, it's impossible to tell when a selection
has been chosen from the list.
I've never used the OnClick event of any control except command
buttons, since I don't see that it actually *means* anything
separate from the AfterUpdate event.

Why do you need to use OnClick instead of AfterUpdate?

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Aug 11 '08 #14

P: n/a
"Gord" <x1******@telus.netwrote in message
news:mbJnk.6310$nu6.5122@edtnps83...
>
The 'After Update' event fires when going to another control as well, not
just clicking a selection from the drop down. Unless I misunderstand
somehow, it's impossible to tell when a selection has been chosen from the
list.
What is the purpose of the code in the Click event?

Keith.

Aug 11 '08 #15

P: n/a
Bob Quintal wrote:
>"Gord" <x1******@telus.netwrote
>The 'After Update' event fires when going to another control as
well, not just clicking a selection from the drop down. Unless I
misunderstand somehow, it's impossible to tell when a selection
has been chosen from the list.
There is the On Not In List event, which is used in conjunction with
the Limit to List property, so that action can be taken to update
the source of the list.

If you set the Limit to list to No, then you could simulate it with
a little code in the After update event to compare the current value
with all the values in the list. Then you will know if the selection
came from the list or is an unlisted value.
Bob, I don't see how the NotInList event is relevant to the
Op's question. It seems to me that your comment about the
AfterUpdate event was sufficient.

Regardless of what I see or don't see about relevance, you
can simulate NotInList in the AfterUpdate event by just
checking the LintIndex property:

If Me.combo.ListIndex = -1 Then
'entry is not in the list
Else
'it is in the list
End If

--
Marsh
Aug 11 '08 #16

P: n/a
Greetings Marshall,

Marshall Barton <ma*********@wowway.comwrote in
news:6f********************************@4ax.com:
Bob Quintal wrote:
>>"Gord" <x1******@telus.netwrote
>>The 'After Update' event fires when going to another control as
well, not just clicking a selection from the drop down. Unless
I misunderstand somehow, it's impossible to tell when a
selection has been chosen from the list.
There is the On Not In List event, which is used in conjunction
with the Limit to List property, so that action can be taken to
update the source of the list.

If you set the Limit to list to No, then you could simulate it
with a little code in the After update event to compare the
current value with all the values in the list. Then you will know
if the selection came from the list or is an unlisted value.

Bob, I don't see how the NotInList event is relevant to the
Op's question. It seems to me that your comment about the
AfterUpdate event was sufficient.
The OP has been rather reticent about "What" he is trying to
accomplish. He's been concentrating on the "How". He may very well
be trying to create functionality that already exists. By mentioning
not in list, I was hoping to trigger some associative reactions to
the "What" in his mind. But you are right, it was a stab in the
dark.
>
Regardless of what I see or don't see about relevance, you
can simulate NotInList in the AfterUpdate event by just
checking the LintIndex property:

If Me.combo.ListIndex = -1 Then
'entry is not in the list
Else
'it is in the list
End If

--
Marsh
Good tip, Thanks. You made my day, teaching me this.

--
Bob Quintal

PA is y I've altered my email address.
** Posted from http://www.teranews.com **
Aug 12 '08 #17

P: n/a
Bob / Marshall.

Thanks for your interest in this problem. It's giving me something more to
chew on.

I'm teaching myself Access from books (and what feedback I get on some posts
I've made here). I have a little bit of experience with VB from playing
around with it on my own.

I'm working on creating a database to keep records on the bit of stock
trading I do. (wins and losses.... mostly losses!) Anyway, the 'what' of
what I'm trying to do is to automatically fill in some other combo boxes on
the form if the selection has been made from the list. If a selection is
made from the combo's list, then I know without question that the data being
entered relates to existing records in the database. It was just a little
bit of convenience I was trying to build into the data entry form and
potentially would make some of the code I would write a little less
complicated. I may not be designing the whole database in the best most
efficient way but it's a work in progress and I can't even say myself
exactly how it's going to look when I'm finished. My specific problem was
that the 'On Click' event could not be relied upon to indicate that a
selection was made just from the list. If other events would accomplish
this or are better to use anyway i.e. AfterUpdate, then that is what I'd
use.

I get the sense from most of the replies in this thread that "what's the big
deal so long as you know there's been a change in the box?" I don't get
this. It seems obvious to me that there could be times when a programmer
needs to know if an event indicates a selection is being made off of the
drop down list or not. Whether my particular situation is a good or bad
idea isn't really important. If an event triggers on some other event that
it's not advertised as triggering on, then I would call that a bug. If the
'On Click' isn't the right event to expect this behaviour from, then I find
it hard to believe there isn't one that does?

Thanks for the ListIndex suggestion Marshall. If my choice of events won't
provide the functionality I need, I think I can get the results I want from
your idea. Won't be able to get to work on it for a couple of days though.

Thanks again

Gord

"Bob Quintal" <rq******@sPAmpatico.cawrote in message
news:Xn**********************@66.175.223.2...
Greetings Marshall,

Marshall Barton <ma*********@wowway.comwrote in
news:6f********************************@4ax.com:
>Bob Quintal wrote:
>>>"Gord" <x1******@telus.netwrote
The 'After Update' event fires when going to another control as
well, not just clicking a selection from the drop down. Unless
I misunderstand somehow, it's impossible to tell when a
selection has been chosen from the list.

There is the On Not In List event, which is used in conjunction
with the Limit to List property, so that action can be taken to
update the source of the list.

If you set the Limit to list to No, then you could simulate it
with a little code in the After update event to compare the
current value with all the values in the list. Then you will know
if the selection came from the list or is an unlisted value.

Bob, I don't see how the NotInList event is relevant to the
Op's question. It seems to me that your comment about the
AfterUpdate event was sufficient.

The OP has been rather reticent about "What" he is trying to
accomplish. He's been concentrating on the "How". He may very well
be trying to create functionality that already exists. By mentioning
not in list, I was hoping to trigger some associative reactions to
the "What" in his mind. But you are right, it was a stab in the
dark.
>>
Regardless of what I see or don't see about relevance, you
can simulate NotInList in the AfterUpdate event by just
checking the LintIndex property:

If Me.combo.ListIndex = -1 Then
'entry is not in the list
Else
'it is in the list
End If

--
Marsh
Good tip, Thanks. You made my day, teaching me this.

--
Bob Quintal

PA is y I've altered my email address.
** Posted from http://www.teranews.com **

Aug 12 '08 #18

P: n/a
Well done, Bob. You were dead on about what the OP was
trying to do. Since it doesn't matter whether a user
selects an item in the list by typing or clicking, all he
needs to know is if it is in the list or not.

--
Marsh
Aug 15 '08 #19

P: n/a
Marshall Barton <ma*********@wowway.comwrote in
news:kd********************************@4ax.com:
Well done, Bob. You were dead on about what the OP was
trying to do. Since it doesn't matter whether a user
selects an item in the list by typing or clicking, all he
needs to know is if it is in the list or not.

--
Marsh
Thank you for the compliment Marshall. Translating the symptom
(what's asked) into what is the real ailment (the Diagnosis) is a
skill I've spent 40 years learning. Still don't always get it right.


--
Bob Quintal

PA is y I've altered my email address.
** Posted from http://www.teranews.com **
Aug 15 '08 #20

P: n/a
On Aug 12, 1:39*am, "Gord" <x1gor...@telus.netwrote:
Bob / Marshall.

Thanks for your interest in this problem. *It's giving me something more to
chew on.

I'm teaching myself Access from books (and what feedback I get on some posts
I've made here). *I have a little bit of experience with VB from playing
around with it on my own.

I'm working on creating a database to keep records on the bit of stock
trading I do. *(wins and losses.... mostly losses!) *Anyway, the 'what' of
what I'm trying to do is to automatically fill in some other combo boxes on
the form if the selection has been made from the list. *If a selection is
made from the combo's list, then I know without question that the data being
entered relates to existing records in the database. *It was just a little
bit of convenience I was trying to build into the data entry form and
potentially would make some of the code I would write a little less
complicated. *I may not be designing the whole database in the best most
efficient way but it's a work in progress and I can't even say myself
exactly how it's going to look when I'm finished. *My specific problem was
that the 'On Click' event could not be relied upon to indicate that a
selection was made just from the list. *If other events would accomplish
this or are better to use anyway i.e. AfterUpdate, then that is what I'd
use.

I get the sense from most of the replies in this thread that "what's the big
deal so long as you know there's been a change in the box?" *I don't get
this. *It seems obvious to me that there could be times when a programmer
needs to know if an event indicates a selection is being made off of the
drop down list or not. *Whether my particular situation is a good or bad
idea isn't really important. *If an event triggers on some other event that
it's not advertised as triggering on, then I would call that a bug. *Ifthe
'On Click' isn't the right event to expect this behaviour from, then I find
it hard to believe there isn't one that does?
Gord,

The actual question that the programmer needs to ask is "Does the data
related to this entry already exist". It doesn't matter how this entry
was created, by clicking or typing directly, as long as you can test
whether the data is there or not. That's why the need to know how it
got there is irrelevant. If you type MSFT in the textbox portion of
the combo of stock symbols, or click on MSFT, the real need is to
determine "Can we lookup data for MSFT".

Only after determining the real need can the programmer decide the
best way to accomplish his goal of building the perfect program.
Thanks for the ListIndex suggestion Marshall. *If my choice of events won't
provide the functionality I need, I think I can get the results I want from
your idea. *Won't be able to get to work on it for a couple of days though.

Thanks again

Gord

"Bob Quintal" <rquin...@sPAmpatico.cawrote in message

news:Xn**********************@66.175.223.2...
Greetings Marshall,
Marshall Barton <marshbar...@wowway.comwrote in
news:6f********************************@4ax.com:
Bob Quintal wrote:
>>"Gord" <x1gor...@telus.netwrote
The 'After Update' event fires when going to another control as
well, not just clicking a selection from the drop down. *Unless
I misunderstand somehow, it's impossible to tell when a
selection has been chosen from the list.
>>There is the On Not In List event, which is used in conjunction
with the Limit to List property, so that action can be taken to
update the source of the list.
>>If you set the Limit to list to No, then you could simulate it
with a little code in the After update event to compare the
current value with all the values in the list. Then you will know
if the selection came from the list or is an unlisted value.
Bob, *I don't see how the NotInList event is relevant to the
Op's question. *It seems to me that your comment about the
AfterUpdate event was sufficient.
The OP has been rather reticent about "What" he is trying to
accomplish. He's been concentrating on the "How". He may very well
be trying to create functionality that already exists. By mentioning
not in list, I was hoping to trigger some associative reactions to
the "What" in his mind. But you are right, it was a stab in the
dark.
Regardless of what I see or don't see about relevance, you
can simulate NotInList in the AfterUpdate event by just
checking the LintIndex property:
* * *If Me.combo.ListIndex = -1 Then
* * * * * 'entry is not in the list
* * *Else
* * * * * 'it is in the list
* * *End If
--
Marsh
Good tip, Thanks. You made my day, teaching me this.
--
Bob Quintal
PA is y I've altered my email address.
** Posted fromhttp://www.teranews.com**
Aug 15 '08 #21

P: n/a

This is bizarre... Im having similar problems with the combobox
AfterUpdate event:

Im running Access 2003.

I created an unbound combobox with 3 columns on a form.
The Row Source is from a table.
Bound Column = 1 and LimitToList = No,,, thus the user can edit the data
in the 1st-Column after they selected one of the rows in the combobox.

However, I want to save the data of 2nd-Column and 3rd-Column, because
if the user edits the 1st-column, the resulting text might not be in the
Row Source, which will result in 2nd-Column and 3rd-Column to go blank.

I thus created two text boxes (TextA and TextB) to store the values of
2nd-Column and 3rd-Column each time the user selects a row from the
combobox.

I entered the following code for the Combobox's AfterUpdate event:

Private Sub InvoiceDetailCombo_AfterUpdate()
TextA = [Forms]![Mainform1]![InvoiceDetailCombo].[Column](1)
'2nd-Column
TextB = [Forms]![Mainform1]![InvoiceDetailCombo].[Column](2)
'3rd-Column
MsgBox "After Update" 'Just to make sure the event fires
End Sub

Now, if I select a row in the Combobox. Everything works fine. The data
is copied to TextA and TextB and my little "After Update" message pops
up.

Then I edit the text in the Combobox.
When I click the mouse on another control, the new edited data in
1st-Column is not found in the Row Source, which results in blanks/nulls
being copied to TextA and TextB and the "After Update" message is
displayed. Everything OK so far.

But, if I ever-so-lightly click on another control after the
1st-Column's data was edited (as if the combobox only lost focus), the
"After Update" message still appears but this time no data is copied to
TextA or TextB (you can even test the values of TextA and TextB with a
query - they still have their old values).

It appears that the pressure of your finger on the mouse button
influences something. However it does not look as if the entire
AfterUpdate event was skipped, because my little message still came up -
yet TextA and TextB were left unchanged.

It also works the same if you press the right-mouse-button.

What is more... they way the text in 1st-Column was edited also has an
influence.
If text is added, TextA and TextB are left unchanged. But if some of the
text is deleted, TextA and TextB are updated every time - regardless of
left or right button or finger pressure.

I'm dumb folded
*** Sent via Developersdex http://www.developersdex.com ***
Sep 24 '08 #22

This discussion thread is closed

Replies have been disabled for this discussion.