Solved

Calling a module in a form.

Posted on 1998-09-09
2
208 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
2 Comments
 
LVL 5

Accepted Solution

by:
yronnen earned 50 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

770 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