I have an Access form to be used for data entry of returned bus surveys. The survey consists of 15 questions and several of the questions will be options groups in the form. For example, question 1 is “When you boarded the bus today, where were you coming from?” The available options are (1) Home, (2) Work, (3) Shopping, ect. I want the data entry person to be able to either select the radio button with the mouse OR be able to tab through hit the appropriate number on the keyboard, (1 for home, 2 for work…) when the first control in the group has focus. I haven’t been able to find any examples of using the On KeyPress event (if that is the right one) in this way. Could someone point me in the right direction?
4 2339 ADezii 8,834
Recognized Expert Expert @luvgis
It is not exactly intuitive how this can be done since an Option Group does not have any Key Events, but here is a little trickery that you can try: - Set the KeyPreview Property of the Form = Yes which will allow the Form to process any Keystrokes prior to any Controls contained within the Form.
- In the Form's KeyPress() Event, make sure the specific Option Group has the Focus, in this case I'll name it optComingFrom.
- Select the appropriate Option in the Option Group if either a 1, 2, or 3 is pressed on the Keyboard.
- Private Sub Form_KeyPress(KeyAscii As Integer)
-
If Screen.ActiveControl.Name = "optComingFrom" Then
-
Select Case KeyAscii
-
Case vbKey1
-
Me![optComingFrom] = 1
-
Case vbKey2
-
Me![optComingFrom] = 2
-
Case vbKey3
-
Me![optComingFrom] = 3
-
Case Else
-
'not really concerned
-
End Select
-
End If
-
End Sub
- Expand the concept for additional Option Groups on the Form.
Thank you so much, your directions were perfect.
I kept looking for the "OnKeyPress " property of the Details section of the form when I should of been looking at the properties of the form itself (which by the way for other newbies can be viewed by right clicking in the little square on the upper left-hand corner of the form in design view). I added a "highlight box" to show up when the control group is active so the user would know which question they were on. I want to share the code for anyone else who may be interested... - Private Sub Form_KeyPress(KeyAscii As Integer)
-
-
If Screen.ActiveControl.Name = "Frame_Question1" _
-
Then
-
-
'Highlight the question
-
Me.HighlightBox_Question1.Visible = True
-
-
Select Case KeyAscii
-
Case vbKey1
-
Me!Frame_Question1 = 1
-
Case vbKey2
-
Me!Frame_Question1 = 2
-
Case vbKey3
-
Me!Frame_Question1 = 3
-
Case vbKey4
-
Me!Frame_Question1 = 4
-
Case vbKey5
-
Me!Frame_Question1 = 5
-
Case vbKey6
-
Me!Frame_Question1 = 6
-
Case vbKey7
-
Me!Frame_Question1 = 7
-
Case vbKey8
-
Me!Frame_Question1 = 8
-
Case vbKey9
-
Me!Frame_Question1 = 9
-
Case vbKey0
-
Me!Frame_Question1 = 10
-
Case Else
-
'not really concerned
-
End Select
-
End If
-
-
If Screen.ActiveControl.Name <> "Frame_Question1" _
-
Then
-
-
'Remove Highlight
-
Me.HighlightBox_Question1.Visible = False
-
-
End If
-
-
End Sub
ADezii 8,834
Recognized Expert Expert
Glad it all worked out for you.
NeoPa 32,564
Recognized Expert Moderator MVP
By placing an ampersand character (&) before the digits in the associated labels, it is possible to press Alt- followed by the associated digit to trigger the button automatically.
This isn't exactly what's requested I know, but it does the benefit of being an inbuilt, available option.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Dan Williams |
last post by:
I have a simple select form element object and want to be able to get it to
select whatever the user chooses when they right-click in it.
I've managed to use the following code, but on the right-click it displays
whatever was previously selected and still highlighted with the left click.
Is there a way to get a right click in the select...
|
by: Ryan McGeary |
last post by:
In a <select> drop-down, the onchange event isn't called when
scrolling through the dropdown using the mouse-wheel and when crossing
over a new <optgroup>.
Using the example below, notice how the onchange event isn't called
when mouse wheel scrolling between A3 and B1, but it works properly
when scrolling between A1 and A2.
E.g....
|
by: Robert |
last post by:
Hello.
I have been trying out the Lebans ToolTip Classes at
http://www.lebans.com/tooltip.htm, to display "balloon" style help tips in a
form. The classes I am using are located at
http://www.lebans.com/DownloadFiles/A2kTooltip.zip
So far the classes work perfectly, except that now I need to extend it to
support other controls besides...
|
by: Colin Anderson |
last post by:
I discovered, with great excitement, this article
http://www.davison.uk.net/vb2notes.asp when researching methods for
emailing from Access via Notes. Unfortunatly, when I run this I get a
Run-time error. When I run it on an XP machine it crashes, but on an
NT box it just generates an unknown error, handled by the error
handler. I have...
|
by: Grasshopper |
last post by:
Hi,
I am automating Access reports to PDF using PDF Writer 6.0. I've
created a DTS package to run the reports and schedule a job to run this
DTS package. If I PC Anywhere into the server on where the job is
running, the job runs sucessfully, PDF files got generated, everything
is good. If I scheduled the job to run at the time that I am...
| |
by: Eric |
last post by:
Hi. I have this Combobox name 'Origin' that contains all states and
countries. I would like to create two Radio buttons (State and
Country) that when you select State, the combobox will query only the
states and vice versa for country. I've create two columns in the
Origin table (OriginState and OriginCountry) and set the data type to
'bit'...
|
by: JHite |
last post by:
I am using Access 2003 on Windows XP.
This is a simple database that contains “tblStaffers” containing names of the office staffers, “tblProjects” containing names of the office projects, and “tblStatusReports” containing the “StafferID” (link to Staffer table), the “ProjectID” (link to Projects table), a “Date” field, and a “Notes” field.
...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |