Results 1 to 8 of 8
  1. #1
    Join Date
    May 2004
    Posts
    65

    Unanswered: Trapping Delete Key

    I have a listbox. If a line is selected and the delete button is clicked the record deletes and the listbox is requeried.

    I want to be able to do this when the user also presses the delete key.

    I can trap any ascii key using the On Keypress but it does not trap edit keys.

    Any help would be appreciated.

  2. #2
    Join Date
    May 2004
    Location
    Moscow, Russia
    Posts
    29
    Code:
    Access Help:
    Removes an item from the list of values displayed by the specified list box control or combo box control.
    expression.RemoveItem(Index)
    Index   Required Variant. The item to be removed from the list, expressed as either an item number or the list item text.
    Remarks
    This method is only valid for list box or combo box controls on forms. Also, the RowSourceType property of the control must be set to "Value List".

    if RowSourceType <> "Value List".

    run sql script for delete item from source table
    then lisbox.requery

  3. #3
    Join Date
    May 2004
    Posts
    65

    Thanks... But I need to trap the Delete Key Press

    Does anyone have any ideas?
    Last edited by gavinfm; 05-21-04 at 12:45.

  4. #4
    Join Date
    May 2004
    Posts
    65

    Any Ideas?

    Any Ideas?

  5. #5
    Join Date
    Feb 2004
    Posts
    142
    Use the keydown event with the form preview set to yes.

    Delete = KeyCode: 46, Shift: 0
    KC

  6. #6
    Join Date
    May 2004
    Posts
    65

    Thanks

    I will give it a go

  7. #7
    Join Date
    Nov 2003
    Posts
    1,487
    In the KeyDown event:

    Code:
    If KeyCode = vbKeyDelete Then
       'Enter your code here that you want
       'to use once the Delete key is trapped.
       KeyCode = 0
    End If

  8. #8
    Join Date
    May 2004
    Posts
    65

    Thanks CyberLynx - You're a Legend

    Works a treat! Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •