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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete key does not trigger On Key Up event

Status
Not open for further replies.

alr0

Programmer
May 9, 2001
211
US
Hi All,

I am upgrading an Access 2.0 application to 2000 and have a feature that does not work for properly.

In the original app, each control runs code triggered by the “On Key Up” event to see if the record is dirty. If so, the record movement is disabled and the user must choose to save or cancel changes.

This works as expected in all but one case. When a controls data is highlighted, (not edit mode) if the users presses the “Delete” key, data is deleted but the it seems that the event is not triggered and the user can change records thereby unintentionally saving changes. Touching any key thereafter, (even the delete key) triggers the event with the expected behaviour. I tried the “On Key Down” and “On Key Press” events with the same results. Possibly this is related to being in edit mode within the control but I am stumped. This never came up when running on 2.0 but I do not have an easy way to check this anymore.

I searched the knowledge base plus help and found nothing about this problem but perhaps someone out there has run into this before or has a suggestion.

Thanks,

alr
 
You could try the Before Update event. This event happends just before a record is saved. No mater how the record was changed. (it is not looking to see if you pressed a key in order to detect a change.)


Private Sub Form_BeforeUpdate(Cancel As Integer)

If MsgBox("Record has been Changed. Do you want to save the changes?", vbYesNo , "Save Record") = vbNo Then

'Undo changes
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
End If

End Sub


Hope this helps.
Pierre
 
Hi Dalain,

Thanks very much for your response.

I may have to use this as a fall back but I was hoping to leave the look and feel as it has been for the last eight years. It is also very curious why delete does not trigger the "On Key" events.

If anyone else has some experience or thoughts about how to track this down I would be most appreciative.

Thanks again,

alr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top