Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Form Name as perameter

Posted on 1999-08-01
7
Medium Priority
?
133 Views
Last Modified: 2010-04-30
I want to control a Form from a function but the form name is a parameter being sent to the function.  This function will be used over may forms and I have to control the calling form.
0
Comment
Question by:ChirsJB
[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
7 Comments
 
LVL 12

Expert Comment

by:mark2150
ID: 1528779
PUBLIC FUNCTION myfun(Obj AS OBJECT)

This will work just fine...

M

0
 

Author Comment

by:ChirsJB
ID: 1528780
More Info:  I'm sending the Form Name over as a string "Form_Name".  Then I "lookup" where the form was located on the screen the last time the Form was unloaded. After that I want to set the Form.top & Form.left of the calling form to last screen location.   I tried "Dim The_Form as Object" but how do I set the Object to the Form_Name string.  
0
 
LVL 10

Expert Comment

by:smegghead
ID: 1528781
hmmm, the only way I can think of doing this is to use the forms control array...

dim frm as form
dim found as boolean
dim frx%,fry%
frx=0:fry=0
found=false ' just to be sure...
for each frm in forms
 if frm.name=form_name then found=true:exit for
next frm
if found then frx=frm.left:fry=frm.top

excuse the syntax / accuracy - I've just typed it straight in here...
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.

 
LVL 10

Expert Comment

by:smegghead
ID: 1528782
The only situation in which the above won't work is when the form you are looking for is not loaded - as the forms collection only applies to loaded forms.

ps. correction to above comment...
 forms control array = forms collection
0
 
LVL 3

Accepted Solution

by:
kfrick earned 30 total points
ID: 1528783
You can pass a reference to the entire form, instead of a string containing the form's name.

Try putting this sub in a module:

Sub RePositionForm (frmCalling as Form)
Dim szName as string, intTop as Integer, intLeft as Integer
  szName = frmCalling.Name
  ' add your look-up code here
  intTop = (your look-up value)
  intLeft = (your look-up value)
  ' now set the position
  frmCalling.Top = intTop
  frmCalling.Left = intLeft
End Sub

Then, on the Calling Form, use the following code....

Sub Form_Load()
  Reposition Me
End Sub

hope this helps!
-kf

0
 

Author Comment

by:ChirsJB
ID: 1528784
No perfect but you put me on the right track. Thanks

0
 
LVL 10

Expert Comment

by:smegghead
ID: 1528785
right... I thought the whole point in the question was to identify the form from a form name passed as a string ???

I'm not going to sqabble about 10pts anyway.
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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

688 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