Microsoft Knowledge Base Email Alertz

KBAlertz.com: This article shows you how to use Visual Basic for Applications to open multiple instances of a form. Being able to open multiple instances of a form enables you to work on more than one record at once. For example, in an Order Entry applic

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]

Search KbAlertz

Advanced Search

Webmasters
Put kbAlertz on your website.
[ Click Here for more! ]





ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **


Bug Tracking Software
For bug tracking software or defect tracking software or issue tracking software, visit Axosoft.


Community Site



We Send hundreds of thousands of emails using ASP.NET Email



Expert Web Design & Graphic Design
Design44.com

ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **




Mentioned In








Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks




Article ID: 135369 - Last Review: January 19, 2007 - Revision: 3.4

ACC: How to Open Multiple Instances of a Form

This article was previously published under Q135369

SUMMARY

Moderate: Requires basic macro, coding, and interoperability skills.

This article shows you how to use Visual Basic for Applications to open multiple instances of a form. Being able to open multiple instances of a form enables you to work on more than one record at once. For example, in an Order Entry application, you can start taking an order, pause and take a second order, and then return to the first order, without losing any data.

NOTE: This article explains a technique demonstrated in the sample files, FrmSampl.exe (for Microsoft Access for Windows 95 version 7.0) and FrmSmp97.exe (for Microsoft Access 97). For information about how to obtain these sample files, please see the following articles in the Microsoft Knowledge Base:
150895  (http://kbalertz.com/Feedback.aspx?kbNumber=150895/EN-US/ ) ACC95: Microsoft Access Sample Forms Available in Download Center
175066  (http://kbalertz.com/Feedback.aspx?kbNumber=175066/EN-US/ ) ACC97: Microsoft Access 97 Sample Forms Available in Download Center
This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to your version of the "Building Applications with Microsoft Access" manual.

MORE INFORMATION

The syntax for opening multiple instances of a form includes a Set statement, the keyword "New" (without the quotation marks), and a form reference, as in the following example:
Set x = New Form_Form1
				
When you open multiple instances of a form, the original instance is the only form object that is stored permanently in the database. The other instances are temporary and are removed from memory when you close them.

NOTE: When you close the original instance of a form, all other instances of the form are closed as well.

To open multiple instances of a form, follow these steps.

CAUTION: Following the steps in this example will modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and perform these steps on a copy of the database.
  1. Open the sample database Northwind.mdb.
  2. Open the Customers form in Design view.
  3. On the View menu, click Code.
  4. Type the following text in the module's Declarations section:
          Option Compare Database
          Option Explicit
          Dim x as Form
    					
  5. Close the Module window.
  6. Add a command button to the Customers form and set the following properties:
    Name: OpenNewCust
    Caption: Open Customers
    OnClick: [Event Procedure]
  7. Set the OnClick property of the command button to the following event procedure:
          Private Sub OpenNewCust_Click()
          Set x = New Form_Customers
          x.setfocus
          End Sub
    					
  8. Close and save the Customers form.
  9. View the Customers form in Form view and click the command button. Note that a second instance of the Customers form opens.

REFERENCES

For more information about using the keyword "New" with a Set statement, search for "Set," and then "Set Statement" using the Microsoft Access 97 Help Index.

APPLIES TO
  • Microsoft Access 95 Standard Edition
  • Microsoft Access 97 Standard Edition
Keywords: 
kbhowto kbprogramming kbusage KB135369
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Be the first to leave feedback, to help others about this knowledge base article.

(Optional) Name

(Optional) Public URL Or Email

Comments
No HTML -- Text Only Please