?
Solved

Sendkeys

Posted on 2003-03-05
3
Medium Priority
?
288 Views
Last Modified: 2010-05-01
Hi,

in my form there are 7 controls. how can I use Sendkeys to go through them like the Tab Key whenever i press Enter?
please give me a complete code showing the event where i use this property.

thanx
0
Comment
Question by:asns
[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
  • 2
3 Comments
 
LVL 7

Expert Comment

by:fluglash
ID: 8073524
Private Sub object_KeyPress([index As Integer,]keyascii As Integer)

The KeyPress event syntax has these parts:

Part Description
object --- An object expression that evaluates to an object in the Applies To list.
index --- An integer that uniquely identifies a control if it's in a control array.
keyascii --- An integer that returns a standard numeric ANSI keycode. Keyascii is passed by reference; changing it sends a different character to the object. Changing keyascii to 0 cancels the keystroke so the object receives no character.

if KeyAscii = 13 then sendkeys "{Tab}"
0
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 200 total points
ID: 8073670
set form.keypreview property to True, in Keypress event of the form put this:
If KeyAscii = 13 Then SendKeys "{Tab}"
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8074515
Just take in mind that it would set focus to every control in your form, not only text boxes.
Thanks for "A" grade.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month13 days, 17 hours left to enroll

800 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