field OnChange event isn't working correctly !!??

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

running access 2k;

I have a pulldown field (limited to list) which has 3 choices. I have
2 fields after it that get populated w/ values when my pulldown value
changes - using the OnChange event for the pulldown.

This works PERFECTLY - IF I use the mouse to change the value.

HOWEVER - IF I use the keyboard, and type the 1st letter of a value,
the OnChange code never executes!!!! ?????

what's more:
if I back-tab, and hit the same character AGAIN, then it changes!!
if I back-tab, and hit a different choice - I get the values for my
PREVIOUS choice !!!????

can ne1 give me a clue?

tia - Bob
 
Bob said:
running access 2k;

I have a pulldown field (limited to list) which has 3 choices. I have
2 fields after it that get populated w/ values when my pulldown value
changes - using the OnChange event for the pulldown.

This works PERFECTLY - IF I use the mouse to change the value.

HOWEVER - IF I use the keyboard, and type the 1st letter of a value,
the OnChange code never executes!!!! ?????

what's more:
if I back-tab, and hit the same character AGAIN, then it changes!!
if I back-tab, and hit a different choice - I get the values for my
PREVIOUS choice !!!????

Why not just use AfterUpdate?
 
Why not just use AfterUpdate?

Thanks for the suggestion, Rick; I'll certainly give that a try.

but just out of curiosity - why wouldn't OnChange work correctly?

tia - Bob
 
Bob said:
hi again !

guess what - EXACT same problem using AfterUpdate !!!!!????

ne other thoughts?

The thing I don't understand is that the Help file suggests that the exact
opposite of what you see should be happening when using the OnChange event.
It indicates that the Change event will be fired as you are typing
characters, but NOT when you change selections in the list.

AfterUpdate should fire regardless, but it won't do so until you leave the
control.
 
The thing I don't understand is that the Help file suggests that the exact
opposite of what you see should be happening when using the OnChange event.
It indicates that the Change event will be fired as you are typing
characters, but NOT when you change selections in the list.

AfterUpdate should fire regardless, but it won't do so until you leave the
control.

Rick;

Your explanation [of AfterUpdate] certainly meets my expectations.
However, if I hit a single key to select an item from the list, and
then tab out - nothing. the event code doesn't fire.

everything with the mouse - perfect.

Bob
 
Bob said:
On Tue, 7 Oct 2003 15:29:09 -0500, "Rick Brandt"
Rick;

Your explanation [of AfterUpdate] certainly meets my expectations.
However, if I hit a single key to select an item from the list, and
then tab out - nothing. the event code doesn't fire.

everything with the mouse - perfect.

Well I believe you would have to press enough keys to hit a match in the list.
Unless you have LimitToList turned off.
 
Bob said:
On Tue, 7 Oct 2003 15:29:09 -0500, "Rick Brandt"
Rick;

Your explanation [of AfterUpdate] certainly meets my expectations.
However, if I hit a single key to select an item from the list, and
then tab out - nothing. the event code doesn't fire.

everything with the mouse - perfect.

Well I believe you would have to press enough keys to hit a match in the list.
Unless you have LimitToList turned off.

you are correct.
I DO have limittolist YES.
and I've made sure that the 3 items in my list each start with a
different character.

I had searched the messages, and it doesn't seem like anyone's had
this problem before... I can't believe it. So it leads me to ask is
it me? But for the life of me; I can't see anything I'm doing wrong...

Bob
 
Bob said:
you are correct.
I DO have limittolist YES.
and I've made sure that the 3 items in my list each start with a
different character.

I had searched the messages, and it doesn't seem like anyone's had
this problem before... I can't believe it. So it leads me to ask is
it me? But for the life of me; I can't see anything I'm doing wrong...

I just performed the following test. I created a new, unbound form and
dropped an unbound ComboBox on it. The ComboBox is using a ValueList with
three entries "abc", "def", "ghi". I added code to display a MsgBox in the
AfterUpdate event of the ComboBox.

If I tab into the Combo, enter the letter "a", and then hit <Tab> or
<Enter>, the ComboBox value becomes "abc" and the MsgBox is displayed.
 
Rick and Bob, I've been ready your messages back and forth and it soulds
like the event is being triggered correctly. Bob, what is the code you have
running? It sounds to me like there is something in the code causing the
problem and not the event itself. If the problem is occuring on both the
OnChange and AfterUpdate events I would guess it is the code. Bob, can you
post your complete code?

Kelvin
 
Kevin;
very happy to:

-----------
Private Sub risk_factor_Change()
goal = d_goal
danger = d_danger
End Sub
-----------

explanation:
table: smokers - contains [risk_id] which is joined to table risks -
which contains (risk_id), risk_desc, d_goal, d_danger. "risks" has 3
records: {1,"A risk",100,200} {2,"B",150,250} {3,"C",175,311}

risk_factor is my limited to list pulldown with 3 choices (extracted
from "risks" and contains the default goal value and default danger
value)
risk_factor is bound to smokers.risk_id, and displays risk.risk_desc
as the 3 choices.

[goal] & [danger] are stored in the "smokers" table, and are meant to
be populated with the default values when the value of [risk_factor]
changes.

the user may then override the default values with whatever they want.


really not much to it - or so I thought :)

as I've said, I've tried this code in both the OnChange, and
AfterUpdate event triggers.

Both give the same results; perfect operation w/ the mouse, and the
screwy stuff w/ the keybd previously mentioned.

hope you can come up with another idea!!
tia - Bob
 
I just performed the following test. I created a new, unbound form and
dropped an unbound ComboBox on it. The ComboBox is using a ValueList with
three entries "abc", "def", "ghi". I added code to display a MsgBox in the
AfterUpdate event of the ComboBox.

If I tab into the Combo, enter the letter "a", and then hit <Tab> or
<Enter>, the ComboBox value becomes "abc" and the MsgBox is displayed.

I'll try to repeat your test on a fresh database, and let you know
what happens....

Bob
 
I just performed the following test. I created a new, unbound form and
dropped an unbound ComboBox on it. The ComboBox is using a ValueList with
three entries "abc", "def", "ghi". I added code to display a MsgBox in the
AfterUpdate event of the ComboBox.

If I tab into the Combo, enter the letter "a", and then hit <Tab> or
<Enter>, the ComboBox value becomes "abc" and the MsgBox is displayed.

hi again, Rick !

I did try a test in a completely fresh database; got the exact same
problem. My test was slightly more elaborate than yours. I repeated
the guts of what my application does.

same issue - OnChange event runs perfectly if the mouse is used, but
seems to run 1-change behind if the keyboard is used.

here's a link to download my database:

http://www.rjservices.com/~troncons/test-kb-pd.mdb

I'd appreciate any light you can shed !!!

tx - Bob
 
haven't heard back from anyone; was wondering if anyone was able to
check out my link to the database example of the problem...

tia - Bob


Kevin;
very happy to:

-----------
Private Sub risk_factor_Change()
goal = d_goal
danger = d_danger
End Sub
-----------

explanation:
table: smokers - contains [risk_id] which is joined to table risks -
which contains (risk_id), risk_desc, d_goal, d_danger. "risks" has 3
records: {1,"A risk",100,200} {2,"B",150,250} {3,"C",175,311}

risk_factor is my limited to list pulldown with 3 choices (extracted
from "risks" and contains the default goal value and default danger
value)
risk_factor is bound to smokers.risk_id, and displays risk.risk_desc
as the 3 choices.

[goal] & [danger] are stored in the "smokers" table, and are meant to
be populated with the default values when the value of [risk_factor]
changes.

the user may then override the default values with whatever they want.


really not much to it - or so I thought :)

as I've said, I've tried this code in both the OnChange, and
AfterUpdate event triggers.

Both give the same results; perfect operation w/ the mouse, and the
screwy stuff w/ the keybd previously mentioned.

hope you can come up with another idea!!
tia - Bob

Rick and Bob, I've been ready your messages back and forth and it soulds
like the event is being triggered correctly. Bob, what is the code you have
running? It sounds to me like there is something in the code causing the
problem and not the event itself. If the problem is occuring on both the
OnChange and AfterUpdate events I would guess it is the code. Bob, can you
post your complete code?

Kelvin
 
Bob said:
haven't heard back from anyone; was wondering if anyone was able to
check out my link to the database example of the problem...

tia - Bob

I had to wait until I could try your file from work as don't have Access
2000 at home.

I do see what you're describing, but it seems to me that you're trying to
accomplish your goal in a more difficult manner than is necessary. Just
drop the risks table from the RecordSource of the form altogether. Than
add the two columns for the default values to the RowSource of your
ComboBox and make them hidden by setting the column widths to zero. Then
replace your OnChange code with...

goal = risk_id.Column(2)
danger = risk_id.Column(3)

After doing this I no longer see any difference between typing and
selecting from the list.
 
Back
Top