Solved

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

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

809 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