473,405 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

multiple instances of form, with some filter etc

3
the option below works.
Expand|Select|Wrap|Line Numbers
  1. Dim frmMulti As Form
  2. Private Sub cmdNewInstance_Click()
  3.     Set frmMulti = New Form_frmClient
  4.     frmMulti.SetFocus
  5. End Sub
however I would like to open the form with specific filters, example order number based on my current selection.
I would also like to auto populate some fields on the new form based on some rules.

the question is, can you call 'frmMulti.SetFocus' and have your arguments added?

Thanks
Jan 31 '14 #1
5 2204
dsatino
393 256MB
Yes. You can basically do whatever you can dream up...and there are usually ten different ways you can accomplish it.
Jan 31 '14 #2
ADezii
8,834 Expert 8TB
You can create Multiple Instances of a Form each with its own independent Row Source/Filter, and each having its own Unique Window. The concept is as follows:
  1. Select a Criteria for each Form Instance. In my case I used a Combo Box consisting of Employee Names and a Unique Identifier.
  2. Once a selection is made:
    1. Create a New Instance of the Form.
    2. Set the Visible Property of this Instance to True.
    3. Create a Unique Caption for this Instance.
    4. Move the Instances to the Upper Left Corner of the Screen and have their Title Bars displayed for identification.
    5. Add the newly created Instance to a Collection using the Handle of the Instance of the Form as a Key Value.
  3. Whenever you deem necessary click the Command Button to remove all Form Instances from the Collection.
  4. I do realize that tis is a lot to follow so I have Uploaded the Demo that I modified to some extent. The Original Author was Mr. Allen Browne himself.
  5. Any questions, please feel free to ask.
Attached Files
File Type: zip Multiple Form Instances.zip (304.3 KB, 150 views)
Feb 2 '14 #3
myhnws
3
I very appreciate your help, especially for attaching the sample.

I got stuck with an issue,

My report has some settings based on the some fields on my form. Until now I was referencing the form by its name.
However, now that the same form is open multiple times, how do I know which form to reference?

Thanks
Feb 5 '14 #4
ADezii
8,834 Expert 8TB
This is a dilemma since you are creating Multiple Instances of the same Form. You have 2 Options as I see it:
  1. You can set the Caption of the New Form Instance to a Unique ID, in this case I pulled it from the Demo Combo Box (Code Line 11).
  2. Each Unique Form Instance has a Unique Window Handle (Code Line 12) which you can store along with some other identifier to uniquely identify a Form.
    Expand|Select|Wrap|Line Numbers
    1. Public Function fOpenNewInstance()
    2. Dim frm As Form
    3. Static intTop As Integer
    4.  
    5. 'Open a new instance, show it, and set a caption.
    6. Set frm = New Form_frmInstance
    7. frm.Visible = True
    8. 'frm.Caption = "Search Results for [" & Forms!frmSearch![cboEmployees].Column(3) & "]"
    9.  
    10. Debug.Print "Caption", "Handle"
    11. frm.Caption = Forms!frmSearch![cboEmployees].Column(0)
    12. Debug.Print frm.Caption, frm.Hwnd
    13.  
    14. frm.RecordSource = "Select * From tblEmployees Where [EmployeeID]= " & Forms!frmSearch![cboEmployees].Column(0)
    15.  
    16. frm.Move 0, intTop * 350
    17.  
    18. intTop = intTop + 1
    19.  
    20. 'Cascade New Instances for a better view, because if
    21. 'not, they would be stacked on top of one another
    22. 'DoCmd.RunCommand acCmdWindowCascade
    23.  
    24. 'Append it to our collection.
    25. colInstance.Add Item:=frm, Key:=CStr(frm.Hwnd)
    26. Set frm = Nothing
    27. End Function
    28.  
  3. After either Method, you can then set Focus to the appropriate Form Window, as in:
    Expand|Select|Wrap|Line Numbers
    1. Dim frm As Form
    2.  
    3. For Each frm In Application.Forms
    4.   If frm.Caption = "8" Then     'Laura Callahan
    5.     frm.SetFocus
    6.   End If
    7. Next
    8.  
  4. To show how the ID and Handle actually work for each Form Instance, I create 9 distinct Instances of the Base Form which represent each of the Employees. The Debug.Print Statement (Code Line# 12) produces the following OUTPUT:
    Expand|Select|Wrap|Line Numbers
    1. Caption       Handle
    2. 5              1902222 
    3. Caption       Handle
    4. 8              460740 
    5. Caption       Handle
    6. 1              460732 
    7. Caption       Handle
    8. 9              526246 
    9. Caption       Handle
    10. 2              264282 
    11. Caption       Handle
    12. 7              329800 
    13. Caption       Handle
    14. 3              133248 
    15. Caption       Handle
    16. 4              133292 
    17. Caption       Handle
    18. 6              133336 
    19.  
  5. Notice that the Form Captions and Handles are Unique.
  6. Hope that this eliminated some of the confusion, and that I didn't make things worse for you (LOL)
Feb 5 '14 #5
myhnws
3
I see that you really try to help me. Thanks
If I understand you correctly, I will need to make a case (in my report) for all my order numbers (which is unlimited).

Any other solution?

Thanks
Feb 5 '14 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Martin V. | last post by:
Hello, Is the multiple instances capability of SQL2K mature enough for a Production system? We're looking at upgrading our hardware but the proposed solution calls for consolidating two...
1
by: Job Lot | last post by:
How can I prevent multiple instances of MdiChild form? I have a MdiParent form with a DataGrid showing all the clients in the database. User clicks on a row to open MdiChild form which display...
11
by: Mike | last post by:
Looking to find any information on how to properly configure multiple instances of DB2. This is on Win2k db2 ver 7.2. I am basically looking for information on how the multiple instance settings...
12
by: (Pete Cresswell) | last post by:
I know I can open many instances of a given form, but I've never done it. Now I'm analyzing an application where that seems like just the ticket: Many investment funds, *lots* of data points for...
2
by: (Pete Cresswell) | last post by:
I have a situation where a bunch of statistics are being presented based on a mutual fund and a benchmark fund's monthly and quarterly returns for a given period (like 10 years....) The hitch...
11
by: Clark Stevens | last post by:
I just finished a WinForms app in VB.NET. I want to allow the user to be able to run multiple instances of the program like you can with Notepad and Wordpad. The way it is now, once I run the...
3
by: sara | last post by:
I've been reading all the posts on this topic. Most are years old, so I have 2 questions: 1. Is there any improvement on opening the same report multiple times (with different input parameters...
0
by: Bob Harrison | last post by:
After installing the Media SDK and looking at the vb sample I was able to create a control that includes the media player plus other form controls. I want to add multiple instances of this control...
6
by: Bob Alston | last post by:
Looking for someone with experience building apps with multiple instances of forms open. I am building an app for a nonprofit organizations case workers. They provide services to the elderly. ...
4
by: nottarealaddress | last post by:
I'm trying to get my feet wet in VB2005 (our new standard at work after officially stopping new development in VB6 about a month ago). I'm working with a simple sql 2005 table of 50 entries, one...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.