?
Solved

pass a form name to a function

Posted on 2003-03-02
8
Medium Priority
?
128 Views
Last Modified: 2010-05-01
I have function that I want to be able to use in several forms but I cannot figure out how to pass the form name to the function, I have the Function declared as this:
function DrawLayer(frmName as Form, strLyrName as String) and placed in a module. I would also like to know how to pass an adodb connection to a function. Thanks for the Help
0
Comment
Question by:hiller1999
[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
  • 4
  • 3
8 Comments
 
LVL 18

Expert Comment

by:Sethi
ID: 8051380
To pass a form's name use the name property of the form. Place this function in a standard module. Now when you are in Form A pass the value of Form A in the following manner:
DrawLayer Me.Name, "Layer"

Me.name will get the name of the form in which the function is being called.
0
 
LVL 18

Expert Comment

by:Sethi
ID: 8051382
You dont need to pass an ADO Connection to a function. Simply create a Public Connection object in a standard module and use this Connection object anywhere in your application without passing it to any function or sub.
0
 

Author Comment

by:hiller1999
ID: 8052333
Figured it out by trial and error, I needed to remove the Quotation Marks from around the form Name...
Call DrawLayers(frmCO, "polygons")
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Accepted Solution

by:
JRCSystems earned 150 total points
ID: 8052945
A couple of notes:

1. Why are you calling a function and ignoring the return?

2. When passing a form to a sub-routine/function, you
   should ALWAYS use the "ME" keyword.

3. You should also using CONSTANTS rather than multiple
   strings thoughout the program.

   Public Const pcsPOLYGON as string = "POLYGON"
   
   x = DrawLayers(Me, pcsPOLYGON)
0
 

Author Comment

by:hiller1999
ID: 8053358
Figured it out by trial and error, I needed to remove the Quotation Marks from around the form Name...
Call DrawLayers(frmCO, "polygons")
0
 

Author Comment

by:hiller1999
ID: 8054235
Figured it out by trial and error, I needed to remove the Quotation Marks from around the form Name...
Call DrawLayers(frmCO, "polygons")
0
 
LVL 18

Expert Comment

by:Sethi
ID: 8054301
Whay exactly are you posting same sentence again and again??
0
 

Author Comment

by:hiller1999
ID: 8056548
All points are correct, sethi's comment does not work, you cannot pass the form name as me.name, you either need to pass it as the actual form name or the ME keyword and not enclose it in quotes , thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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 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…
Suggested Courses
Course of the Month8 days, 12 hours left to enroll

764 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