M
Michel S.
Hi !
I'm using Access XP and I'm experiencing the following problems with
the comboBox events:
1) If I make a selection in the drop down list using the cursor keys
followed by the enter key, the "After Update" event correctly fires and
my selection appears in the closed box.
From that event, I then set the focus to another field, a textbox.
Upon entering that field, it's "Key press" event fires and the Ascii
value is 13, which is the enter key I used to make my selection in the
combo. Since "Enter" is a valid entry in that specific textbox, I can
hardly disregard it in the text box keypress event.
Question: is there a way to sink that "enter" key before the next field
get its focus ? (Preferably within the combo code itself).
2) If I use my mouse to highlight a choice in the dropdown list and
then press "enter" to confim that selection, the dropdown list closes,
but the combo value stays to its old value.
Is this behavior normal ?
3) Once the combo box is exited (or loose focus ?), I want to assign
its value to a textbox, set the focus to that textbox and then hide the
combo.
For example, in the after update event, I use code like this :
Private Sub cbo_AfterUpdate()
Debug.Print "cbo after update"
With txt
.Value = cbo.Value
.Visible = True
.SetFocus
End With
cbo.Visible = False
Debug.Print "cbo after update exit"
End Sub
Tracing the events sequence in the immediate window, after selecting a
value with the mouse only, I find the following :
cbo after update
cbo exit
cbo enter
txt got focus
cbo after update exit
cbo change
Questions :
a) Why do the cbo Exit and cbo Enter fire in the middle of the after
update event ? Isn't the combo already the active control ?
b) Why are there no "cbo lost focus" or "cbo exit" events after the
text gets the focus ?
Thanks in advance !
I'm using Access XP and I'm experiencing the following problems with
the comboBox events:
1) If I make a selection in the drop down list using the cursor keys
followed by the enter key, the "After Update" event correctly fires and
my selection appears in the closed box.
From that event, I then set the focus to another field, a textbox.
Upon entering that field, it's "Key press" event fires and the Ascii
value is 13, which is the enter key I used to make my selection in the
combo. Since "Enter" is a valid entry in that specific textbox, I can
hardly disregard it in the text box keypress event.
Question: is there a way to sink that "enter" key before the next field
get its focus ? (Preferably within the combo code itself).
2) If I use my mouse to highlight a choice in the dropdown list and
then press "enter" to confim that selection, the dropdown list closes,
but the combo value stays to its old value.
Is this behavior normal ?
3) Once the combo box is exited (or loose focus ?), I want to assign
its value to a textbox, set the focus to that textbox and then hide the
combo.
For example, in the after update event, I use code like this :
Private Sub cbo_AfterUpdate()
Debug.Print "cbo after update"
With txt
.Value = cbo.Value
.Visible = True
.SetFocus
End With
cbo.Visible = False
Debug.Print "cbo after update exit"
End Sub
Tracing the events sequence in the immediate window, after selecting a
value with the mouse only, I find the following :
cbo after update
cbo exit
cbo enter
txt got focus
cbo after update exit
cbo change
Questions :
a) Why do the cbo Exit and cbo Enter fire in the middle of the after
update event ? Isn't the combo already the active control ?
b) Why are there no "cbo lost focus" or "cbo exit" events after the
text gets the focus ?
Thanks in advance !