hi.i need to use form names as i want to refer certain controls in certain forms to other forms.i want to retrieve the form name and store it in a variable.
for example :
i declare a variable

public fname as string

then i retrieve form name and add it into the variable

fname  = (retrieve form name)

then i can use the variable as a reference whenever i jump to other forms.for example:

fname.show

my question is how do i retrieve the form name and is this thing im trying to do possible??

thanx for any help..

Recommended Answers

All 3 Replies

i think no need to retrieve forms name for example you have 3 forms, Form1, Form2, Form3. Form1 is the parent form, then if Form1 loads set the visible property of the two forms to false, or you hide the two forms, then once you need the form to show, then call that particular Form, set the visible property to True to show the form..
hope this helps...

You can get any form from the AllForms Colllection. Here's a little code shippet I lifted from MSDN:

Sub AllForms()
    Dim obj As AccessObject, dbs As Object
    Set dbs = Application.CurrentProject
    ' Search for open AccessObject objects in AllForms collection.
    For Each obj In dbs.AllForms
        If obj.IsLoaded = True Then
            ' Print name of obj.
            Debug.Print obj.Name
        End If
    Next obj
End Sub

The url for the page I found it on is http://msdn2.microsoft.com/en-us/library/bb214271.aspx

Hoppy

The answer is that you cannot do this
(public fname as string)
because string variables do not have the show event!

But you can do this:

public pubForm as form

'and then
set pubForm=Form1
(the real name of the form)
(or -if the code is inside the form- then:
set pubForm=Me
)

'and then
pubForm.show

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.