Enter Key Behavior in Combo Box

D

dwetmore

I have a series of combo boxes that the user will populate at runtime.
I have trapped the "Enter" key to trigger the population code.
However, the "Enter" key also moves the insertion point to the next
combobox. I know I can alter Enter Key behavior for the whole
database, but I would like be able to do it for the controls on one
form which contains both text boxes and combo boxes. I still want to
be able to use Tab to move through the controls but want to disable
the tabbing effect of the Enter Key

How can I do this?

Thanks

Dave Wetmore
 
S

Stuart McCall

I have a series of combo boxes that the user will populate at runtime.
I have trapped the "Enter" key to trigger the population code.
However, the "Enter" key also moves the insertion point to the next
combobox. I know I can alter Enter Key behavior for the whole
database, but I would like be able to do it for the controls on one
form which contains both text boxes and combo boxes. I still want to
be able to use Tab to move through the controls but want to disable
the tabbing effect of the Enter Key

How can I do this?

Thanks

Dave Wetmore

1. Set the form's KeyPreview property to Yes/True
2. Create a KeyDown event procedure for the form
3. In the procedure, type:

If KeyCode = 13 Then KeyCode = 0

That effectively 'throws away' the enter keypress.
 
K

Klatuu

There is a much better way to do this. Use the combo's After Update event to
populate the combo dependent on the value of the current combo. For example,
the row source query of Combo2 could be something like:

Select PooBah From tblBlah Where [Fizz] = Me.Combo1

Then in the After Update of Combo1

If Not IsNull(Me.Combo1) Then
Me.Combo2.Requery
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top