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

By AndrewThackray ·
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 conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

Could be a couple of things that

by Tony Hopkinson In reply to Why does trapping a funct ...

F5 is usually refresh so is it doing that first?
Other one is if you search code is leaving the record, the default action, is to cancel...
Probably have to pick a different key (f3 is a 'standard' for search), for teh first one, the other, you need to post the changes or leave the record alone.

Related Discussions

Related Forums