Solved

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

Posted on 2012-03-23
5
363 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
  • 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server functions 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 Ac…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

786 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