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

x
?
Solved

Using variables to identify objects

Posted on 1997-03-14
1
Medium Priority
?
279 Views
Last Modified: 2006-11-17
Can I use variables to identify objects such as forms.  I know I can use activeform but I would like to use a variable to identify a form.  For example, I want to condense the following code from;
Select Case gs_Form_for_Sort_Plot
    Case "frm_KS01"
        frm_KS01.F1Book1.Sort3 command
        frm_KS01.F1Book1.SetSelection command
        frm_KS01.F1Book1.SetBorder command
    Case "frm_KS02"
        frm_KS02.F1Book1.Sort3 command
        frm_KS02.F1Book1.SetSelection command
        frm_KS02.F1Book1.SetBorder command
    Case "frm_KS03"
        frm_KS03.F1Book1.Sort3 command
        frm_KS03.F1Book1.SetSelection command
        frm_KS03.F1Book1.SetBorder command
    Case Else
        MsgBox "Error in sort."
End Select

To;

gs_Form_for_Sort_Plot.F1Book1.Sort3 command
gs_Form_for_Sort_Plot.F1Book1.SetSelection command
gs_Form_for_Sort_Plot.F1Book1.SetBorder command
0
Comment
Question by:jadekraf
[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
1 Comment
 
LVL 5

Accepted Solution

by:
volking earned 200 total points
ID: 1424479
Sure, just pass the form name to a function/sub as TYPE FORM. Using your example ...

Select Case gs_Form_for_Sort_Plot
    Case "frm_KS01", "frm_KS02",  "frm_KS03"
        MyCode  gs_Form_for_Sort_Plot
    Case Else
        MsgBox "Error in sort."
End Select

Public Sub MyCode ( FormObj  AS FORM )
    FormObj.Sort3 command
    FormObj.SetSelection command
    FormObj.SetBorder command
End Sub
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
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

705 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