Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8789663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:28:22+00:00 2026-06-13T22:28:22+00:00

I am right now programming in MS Access and while going through the properties

  • 0

I am right now programming in MS Access and while going through the properties of a form I have come across a property named ‘key preview’. MS Access documentation tells that it is used to invoke keyboard events for forms before keyboard events for controls.

I am not sure what this means and whay could be possible usage of this property??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:28:23+00:00Added an answer on June 13, 2026 at 10:28 pm

    If the the KeyPreview property is set to true, the form will receive the keyboard event before the control does, giving you a chance to do something with it at the form level.

    Now, imagine that you have a form with many controls on it.
    Imagine that you wish to allow the user to hit the F2 key on the keyboard to perform some action, like opening another form, playing some music, or whatever.

    In Access, like in most UI programming, only one control can receive focus at any one time.
    So if the focus is on a textbox, when you hit F2, that textbox keyboard events will fire.
    You can catch that keypress from the textbox events, but if the user hits F2 from another control, it won’t be detected unless you also detect that F2 was hit from that control itself.

    So to make things easier, you can just set the form to receive the keyboard events first, before they are passed on to the control that has focus, giving you a chance to detect that the user pressed F2 in a single place, rather than having to wire each control to detect that keypress.

    Example

    Add a single textbox mytextbox to a new form.
    In the code behind for the form, add the following events for catching keyboard events for both the form and the textbox:

    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
        Debug.Print "Form_KeyDown(keycode:" & KeyCode & ", Shift:" & Shift & ")"
    End Sub
    
    Private Sub Form_KeyPress(KeyAscii As Integer)
        Debug.Print "Form_KeyPress(KeyAscii:" & KeyAscii & ")"
    End Sub
    
    Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
        Debug.Print "Form_KeyUp(keycode:" & KeyCode & ", Shift:" & Shift & ")"
    End Sub
    
    Private Sub mytextbox_KeyDown(KeyCode As Integer, Shift As Integer)
        Debug.Print "mytextbox_KeyDown(keycode:" & KeyCode & ", Shift:" & Shift & ")"
    End Sub
    
    Private Sub mytextbox_KeyPress(KeyAscii As Integer)
        Debug.Print "mytextbox_KeyPress(KeyAscii:" & KeyAscii & ")"
    End Sub
    
    Private Sub mytextbox_KeyUp(KeyCode As Integer, Shift As Integer)
        Debug.Print "mytextbox_KeyUp(keycode:" & KeyCode & ", Shift:" & Shift & ")"
    End Sub
    

    Now, open the form and type a single key.
    If you hit the Q key, you should see something like this in the immediate window:

    Control Keyboard events

    Only the textbox received the events.

    Now, set the KeyPreview property to true (Yes) and when you open the form and hit Q, you should see that the Form received the Keyboard events first.

    Form and Control Keyboard events

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm in a mobile programming class right now and we have to make a
Right now I have an upload field while uploads files to the server. The
I have been programming for a little while now, and I have a question
Right now, I'm programming a controller for a donation system that uses Payconnect and
Right now, I'm programming the networking for my online game, and I'm not really
I'm programming a game engine right now. The hardest part for me has been
I'm in a mobile programming course right now and we need to create a
im programming a project and im trying to apply multitier architecture. Right now ive
Right now, I have: RewriteRule ^([^/\.]+)?$ index.php?id=$1 [L] to match any username at the
This is been making my programming really frustrating lately. I´m in Argentina right now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.