Solved

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

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

746 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now