• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 130
  • Last Modified:

pass a form name to a function

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
hiller1999
Asked:
hiller1999
  • 4
  • 3
1 Solution
 
SethiCommented:
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
 
SethiCommented:
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
 
hiller1999Author Commented:
Figured it out by trial and error, I needed to remove the Quotation Marks from around the form Name...
Call DrawLayers(frmCO, "polygons")
0
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.

 
JRCSystemsCommented:
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
 
hiller1999Author Commented:
Figured it out by trial and error, I needed to remove the Quotation Marks from around the form Name...
Call DrawLayers(frmCO, "polygons")
0
 
hiller1999Author Commented:
Figured it out by trial and error, I needed to remove the Quotation Marks from around the form Name...
Call DrawLayers(frmCO, "polygons")
0
 
SethiCommented:
Whay exactly are you posting same sentence again and again??
0
 
hiller1999Author Commented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now