Solved

MS access:  trap user click, space bar and move a form

Posted on 2012-03-23
5
376 Views
Last Modified: 2012-08-14
I have a series of data that I want to cycle through on  a form.

Each refresh will increment...hit the DB and return the next set of data.  I have this working with a prev/next button.

I want the functionality like powerpoint...if the user hits the space bar, clicks or uses the arrow keys (back/forward).  I want to trap this and do the refresh of the form.

Any thoughts?

sendkeys??

What event can I use?

thanks tons
0
Comment
Question by:skillilea
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37757111
Just a note...
Powerpoint presentation do not typically require "data entry"

So keys like Tab, Spacebar, mouse clicks  can be used.

In an access form these keys are dedicated...

Sure, ...you can do anything you want.

But how will your app distinguish between a spacebar to refresh, and a space bar between words...?

How about simply using a button?
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 250 total points
ID: 37757133
1. ...and my next question would be why this refresh is needed for each record...?

I mean if you are doing it  with a prev/next button, then you are really doing it on each record.

2. ...If so, then why not just do it on the Current Event of the Form and not ever have to worry about doing it anywhere else?
If Not me.NewRecord then
....'Your "Refresh" code
end if
0
 
LVL 61

Assisted Solution

by:mbizup
mbizup earned 250 total points
ID: 37757170
*IF* the data will be read-only (see Jeff's concerns regarding the distinction of the spacebar for navigation vs data entry.  The arrow keys should be okay regardless), you can use the form's Key-down event to detect the desired keys and move to the next record accordingly:


Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    On Error Resume Next
    Select Case KeyCode  
        Case vbKeySpace, vbKeyLeft, vbKeyRight ' etc
               docmd.RunCommand acCmdRecordsGoToNext
    End Select
End Sub


You can also use similar code in keydown events of individual controls.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37757513
mbizup.

Not sure but I heard that you also have to set the KeyPreview property of the form...?

Not quite sure though...

Jeff
0
 
LVL 61

Expert Comment

by:mbizup
ID: 37757556
Yup...

You can either set that statically through the Form's property sheet , under the Events tab or dynamically in the form's open event:

Me.KeyPreview = True
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question