Solved

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

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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

635 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