Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Advise on how to handle 2 different events

Status
Not open for further replies.

Sullaway

Technical User
Sep 27, 2000
50
0
0
US
Access 97
combo box is on a continuous form.

In one of my combo boxes I have code in the key down event, which works fine
except in one case and that's when a user types data that is not on the
list. I have code that takes them to a separate form to add the new data,
which that works fine also. My problem is that the On Not In List and Key
Down both try to fire. Could someone help me with a way to stop the On Key
Down event from firing if the On Not In List is firing?

Below is the code in the On Key Down and where it pukes is the
Me.cmdClose.SetFocus. Error message says that it can not move the focus to
cmdClose

Code behind On Key Down:
If Me.NewRecord Then
If KeyCode = 9 Then
Me.cmdClose.SetFocus
End If
Else
If KeyCode = 9 Then
Dim recClone As Recordset
Set recClone = Me.RecordsetClone()
recClone.Bookmark = Me.Bookmark
If recClone.EOF Then
Me.cmdClose.SetFocus
Else
DoCmd.GoToRecord acActiveDataObject, , acNext
End If
recClone.Close
End If
End If

TIA
Shane
 
Don't think there is a way to stop the OnKeyDown event from firing before the OnNotInList event.

However, it appears that column(0) (bound column) of the combo box is null if the user did not select an item in the list. Therefore, you could check for the null in the OnKeyDown event.

If it is null, exit the OnKeyDown event.
 
Thanks FancyPrairie,

I did get it to working by putting the code in On Key Up instead of On Key Down but you did bring up an interesting point about the Combo's bound column being null. I believe I will give that a shot and see what happens. Good thinking on your part.

Thanks again,
Shane
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top