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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I use form_ ? 2

Status
Not open for further replies.

dmaranan

Programmer
Aug 14, 2001
46
US
I'm trying to access a form with a space using the form_ method. I know I can do it with Forms!, but I need to know how to do it using the Form_ method. thanks!
 
Never heard of the Form_ method. Where are you getting that from?
 
I found the form_ method in a program that I'm customizing.

The following are equivalent:
Form_ApplicationEntry.firstname
Forms![ApplicationEntry.firstname]
 
That method works just like the Forms![myForm] method, but they are both limited to referencing forms that are already open.

You can create a new instance of a form using that syntax and reference it with a variable:

Code:
Sub OpenAssetsForm()
    Dim f As Form
    
    Set f = New Form_Assets    '<--normally used like this
    
    DoCmd.OpenForm f.Name
    
    Debug.Print &quot;Total Controls on Form &quot; & f.Name
    
    'Next 2 lines do the same thing.

    Debug.Print Form_Assets.Controls.Count
    Debug.Print f.Controls.Count
    
    DoCmd.Close acForm, Form_Assets.Name, acSaveNo
    
End Sub



VBSlammer
redinvader3walking.gif

[sleeping]Unemployed in Houston, Texas
 
dmaranan, I apologize for my reply to your post in the other thread. I was unaware that such a method existed for referring to forms.

But to get back to your question, I tried several variations on VBSlammer's suggestion, but was unable to find any way of referring to a form that has spaces in the name using the Form_ approach. Can you rename your form such that it has no spaces? VBSlammer, do you know of a way?

Ken S.
 
Just enclose the entire name in brackets:

[tt]

strCaption = [Form_Customers In Houston].Caption

[/tt]

VBSlammer
redinvader3walking.gif

[sleeping]Unemployed in Houston, Texas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top