Solved

Multiple Forms & Subs ; Objects in Modules

Posted on 1998-07-05
2
140 Views
Last Modified: 2010-05-03
I am writing some code that talks to some equipment through the COM Port. I use the MSCOMM control and one custom SUB to decifer the output and input from the equipment. I want to talk to this SUB from several Forms, so I tried putting it into a Module so all the forms could see it. But when I run it I get an "Object required" Error (Referring to the MSCOMM Object). But as far as I can tell there is no way to attach or insert an object into a module. I am pretty new at this Language, so should I be using a class module or something. Basically, I want several forms to use the same sub to talk to the COM port. How would I go about doing this.
0
Comment
Question by:willmrk
2 Comments
 
LVL 4

Expert Comment

by:tomook
ID: 1464987
Please show us the code in error. I think I know what the problem is, but I want to be sure I am not leading you down the wrong path.
0
 
LVL 6

Accepted Solution

by:
alamo earned 100 total points
ID: 1464988
You are correct, you can't place an object into a module. There are two ways to do this:

1.Leave the sub in the module and access teh control by qualifying the control name with the form name, e.g

Form1.MSComm1.CommPort = 1

2. Place the sub in the form as Public and call it from outside the form by again qualifying the sub name with the form name. For example

Form1.DecodePacket(packet$)

Hope this helps!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA/SQL - Connect to SQL server and pull data 4 118
Added a column screws up code 5 63
converting visio 2010 to powerpoint 2010  - formatting issues 5 91
Problem to line 23 53
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

791 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