?
Solved

Calling a module in a form.

Posted on 1998-09-09
2
Medium Priority
?
243 Views
Last Modified: 2010-04-30
How do you get a module to run in a form. Here is the code that I have in a module "If (KeyAscii = 13) Then SendKeys "{TAB}"".  I don't want to type it everytime and want to call it from a procedure.
0
Comment
Question by:matthewkwp
[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 Comments
 
LVL 5

Accepted Solution

by:
yronnen earned 200 total points
ID: 1433863
in the module write
public sub ButtonClick(KeyAscii)
If (KeyAscii = 13) Then SendKeys "{TAB}"
end sub

in your keydown event on every form write
ButtonClick(KeyAscii)


0
 
LVL 1

Expert Comment

by:bharris1
ID: 1433864
First you can always 'copy and paste' code.  This has become one of my favorite helpful tips for coding.

Second, the KeyDown event doesn't give you the Ascii code for the key pressed it's in the KeyPress event.

Third, you should be able to call it like anything else.

IN FORM:
Private Sub Text1_KeyPress(KeyAscii As Integer)
    MyProcedure KeyAscii
End Sub

IN MODULE:
Public Sub MyProcedure(KeyAscii As Integer)
    If (KeyAscii = 13) Then SendKeys "{TAB}"
End Sub


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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…
Suggested Courses
Course of the Month11 days, 16 hours left to enroll

752 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