Disable ESC or CTRL+BREAK

Discussion in 'Microsoft Access VBA Modules' started by Dave, Oct 11, 2004.

  1. Dave

    Dave Guest

    I have a subroutine that imports a very large text file, which is
    fairly time consuming, then runs three quick queries afterward. On the
    form where the command button to run this subroutine exists, I do
    inform the users that if they can't wait for the import to finish, to
    press the ESC key. The import takes up 99% of the time for this
    subroutine to finish. I do not want the user to accidently press the
    ESC key however, when the three quick queries are being executed at
    the end of the sub routine (about 5 seconds each). Is there a way to
    just disable ESC or CRTL+BREAK after the import, but before the three
    queries execute, then enable ESC and CRTL+BREAK again after the three
    queries are executed, or at least after the subroutine is finished?

    Thanks,

    Dave
     
    Dave, Oct 11, 2004
    #1
    1. Advertisements

  2. Dave

    solex Guest

    Dave,

    You can go to the menu \\Tools\Startup (Access 2K) and uncheck "Use Access
    Special Keys" in the Advanced Section. This disables the use of CTRL+BREAK.
    Also I would consider uploading the data to temporary table before importing
    to the production tables for saftey reasons.
    Dan

    Assuming your import screen is a modal dialog box, you can set key preview
    in the
    "Dave" <> wrote in message
    news:...
    > I have a subroutine that imports a very large text file, which is
    > fairly time consuming, then runs three quick queries afterward. On the
    > form where the command button to run this subroutine exists, I do
    > inform the users that if they can't wait for the import to finish, to
    > press the ESC key. The import takes up 99% of the time for this
    > subroutine to finish. I do not want the user to accidently press the
    > ESC key however, when the three quick queries are being executed at
    > the end of the sub routine (about 5 seconds each). Is there a way to
    > just disable ESC or CRTL+BREAK after the import, but before the three
    > queries execute, then enable ESC and CRTL+BREAK again after the three
    > queries are executed, or at least after the subroutine is finished?
    >
    > Thanks,
    >
    > Dave
     
    solex, Oct 11, 2004
    #2
    1. Advertisements

  3. Dave

    Alp Guest

    Hi Dave,

    I'm no expert here but here's something I have put together but not tried
    yet. If you feel like, then give it a try and do let me know pease.

    I hope it will work for you.

    Alp

    Code below:
    'Code by: M. Alp Bekisoglu
    'Created: 12/10/2004
    'Contents:___________
    'DisabECB - Disables use of Esc and the Ctrl+Break keys
    'EnabECB - Enables use of Esc and the Ctrl+Break keys
    '
    Private Function DisabECB()
    'Disables Esc and Ctrl+Break keys
    Dim db As DAO.Database
    Dim P As Property
    'Const conPrpNotFound = 3270

    Set db = CurrentDb
    'On Error GoTo conPrpNotFound

    If IsError(db.Properties!AllowBreakIntoCode) = True Then
    'if property is not found then create and set to False

    prpnm = "AllowBreakIntoCode"
    prptype = 1
    prpvalue = 0
    P = db.CreateProperty(prpnm, prptype, prpvalue)
    db.Properties.Append P
    Else
    'if property is found then set to False

    db.Properties(AllowBreakIntoCode) = 0
    End If

    If IsError(db.Properties!AllowSpecialKeys) = True Then
    'if property is not found then create and set to False

    prpnm = "AllowSpecialKeys"
    prptype = 1
    prpvalue = 0
    P = db.CreateProperty(prpnm, prptype, prpvalue)
    db.Properties.Append P
    Else
    'if property is found then set to False

    db.Properties(AllowSpecialKeys) = 0
    End If
    Set db = Nothing
    End Function

    Private Function EnabECB()
    'Enables Esc and Ctrl+Break keys
    Dim db As DAO.Database
    Dim P As Property
    'Const conPrpNotFound = 3270

    Set db = CurrentDb
    'On Error GoTo conPrpNotFound

    If IsError(db.Properties!AllowBreakIntoCode) = True Then
    'if property is not found then create and set to True

    prpnm = "AllowBreakIntoCode"
    prptype = 1
    prpvalue = -1
    P = db.CreateProperty(prpnm, prptype, prpvalue)
    db.Properties.Append P
    Else
    'if property is found then set to True

    db.Properties(AllowBreakIntoCode) = -1
    End If

    If IsError(db.Properties!AllowSpecialKeys) = True Then
    'if property is not found then create and set to True

    prpnm = "AllowSpecialKeys"
    prptype = 1
    prpvalue = -1
    P = db.CreateProperty(prpnm, prptype, prpvalue)
    db.Properties.Append P
    Else
    'if property is found then set to True

    db.Properties(AllowSpecialKeys) = -1
    End If
    Set db = Nothing
    End Function

    "Dave" <> wrote in message
    news:...
    > I have a subroutine that imports a very large text file, which is
    > fairly time consuming, then runs three quick queries afterward. On the
    > form where the command button to run this subroutine exists, I do
    > inform the users that if they can't wait for the import to finish, to
    > press the ESC key. The import takes up 99% of the time for this
    > subroutine to finish. I do not want the user to accidently press the
    > ESC key however, when the three quick queries are being executed at
    > the end of the sub routine (about 5 seconds each). Is there a way to
    > just disable ESC or CRTL+BREAK after the import, but before the three
    > queries execute, then enable ESC and CRTL+BREAK again after the three
    > queries are executed, or at least after the subroutine is finished?
    >
    > Thanks,
    >
    > Dave
     
    Alp, Oct 12, 2004
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SAG

    How to detect if a user hit <Esc> to exit loop

    SAG, Aug 27, 2003, in forum: Microsoft Access VBA Modules
    Replies:
    2
    Views:
    1,283
    Dirk Goldgar
    Aug 29, 2003
  2. rocco

    Canceling Edits / ESC Key

    rocco, Sep 12, 2003, in forum: Microsoft Access VBA Modules
    Replies:
    0
    Views:
    180
    rocco
    Sep 12, 2003
  3. Bill Reed via AccessMonster.com

    How do I accomplish the equivalent of hitting the {ESC} key in code?

    Bill Reed via AccessMonster.com, Apr 29, 2005, in forum: Microsoft Access VBA Modules
    Replies:
    5
    Views:
    772
    Bill Reed via AccessMonster.com
    May 3, 2005
  4. Guest
    Replies:
    1
    Views:
    2,181
    Albert D. Kallal
    May 12, 2007
  5. AlwaysFroosh!

    Closing a Report in Print Preview using the ESC (Escape) Key

    AlwaysFroosh!, Apr 26, 2008, in forum: Microsoft Access VBA Modules
    Replies:
    0
    Views:
    290
    AlwaysFroosh!
    Apr 26, 2008
Loading...

Share This Page