Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Forms

Status
Not open for further replies.

rolandam

Programmer
Joined
Jul 17, 2007
Messages
3
Location
AT
Is there a way to open a form using [highlight #FF99FF]Application.CurrentProject.ALLFORMS. [/highlight]
If have a treeview menu where the user selects the form to open, I'am currently using the DoCmd.OpenForm, which works fine. I however want to set an object variable to the form from the [highlight #FF99FF]Application.CurrentProject.ALLFORMS. [/highlight].
I have the following code to list all the forms
Code:
Public Function StrForm(strName as string) as object
Dim obj as AccessObject
dim dbs as object

set dbs=Application.CurrentProject
For Each obj In dbs.ALLFORMS
         If strName = obj.Name Then 
              Set StrForm = obj
              Exit For
         EndIf
Next 

Set obj = Nothing
Set dbs = Nothing

Exit Function
Thanks
 
How about:

Code:
         If strName = obj.Name Then
              DoCmd.OpenForm strName
              Set StrForm = Forms(strName)
              Exit For
         End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top