Why does trapping a function key in MS Access lose a new record? - TechRepublic
Question
February 17, 2011 at 07:53 PM
andrewthackray

Why does trapping a function key in MS Access lose a new record?

by andrewthackray . Updated 15 years, 4 months ago

I have a transaction form in MS access where I want the user to be able to press a function key (F5) to call up search screens when they are on a customer ID field or a SKU id field and they don’t know the code required.

Using the keydown event traps the function key brillianly if the user is on an existing record.

however if the user is entering a new record with an auto number key, using the keydown, keyup or keypress events on a control seems to force MS access to immediatley write the record to the database and start a new record.

This occurs even if there is no code at all in the key down, keypress or key up event subroutines. The net result is that I have incomplete records in the database and the screen to the user immediately loses whatever has just been entered.

For example the following keydown code containing only a blank comment line causes an immediate record write and new record creation

Private Sub fldWorkOrderType_KeyPress(KeyAscii As Integer)

End Sub

How can I stop this from happening ?

This discussion is locked

All Comments