the option below works. - Dim frmMulti As Form
-
Private Sub cmdNewInstance_Click()
-
Set frmMulti = New Form_frmClient
-
frmMulti.SetFocus
-
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
5 2204
Yes. You can basically do whatever you can dream up...and there are usually ten different ways you can accomplish it.
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: - Select a Criteria for each Form Instance. In my case I used a Combo Box consisting of Employee Names and a Unique Identifier.
- Once a selection is made:
- Create a New Instance of the Form.
- Set the Visible Property of this Instance to True.
- Create a Unique Caption for this Instance.
- Move the Instances to the Upper Left Corner of the Screen and have their Title Bars displayed for identification.
- Add the newly created Instance to a Collection using the Handle of the Instance of the Form as a Key Value.
- Whenever you deem necessary click the Command Button to remove all Form Instances from the Collection.
- 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.
- Any questions, please feel free to ask.
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
This is a dilemma since you are creating Multiple Instances of the same Form. You have 2 Options as I see it: - 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).
- 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.
-
Public Function fOpenNewInstance()
-
Dim frm As Form
-
Static intTop As Integer
-
-
'Open a new instance, show it, and set a caption.
-
Set frm = New Form_frmInstance
-
frm.Visible = True
-
'frm.Caption = "Search Results for [" & Forms!frmSearch![cboEmployees].Column(3) & "]"
-
-
Debug.Print "Caption", "Handle"
-
frm.Caption = Forms!frmSearch![cboEmployees].Column(0)
-
Debug.Print frm.Caption, frm.Hwnd
-
-
frm.RecordSource = "Select * From tblEmployees Where [EmployeeID]= " & Forms!frmSearch![cboEmployees].Column(0)
-
-
frm.Move 0, intTop * 350
-
-
intTop = intTop + 1
-
-
'Cascade New Instances for a better view, because if
-
'not, they would be stacked on top of one another
-
'DoCmd.RunCommand acCmdWindowCascade
-
-
'Append it to our collection.
-
colInstance.Add Item:=frm, Key:=CStr(frm.Hwnd)
-
Set frm = Nothing
-
End Function
-
- After either Method, you can then set Focus to the appropriate Form Window, as in:
-
Dim frm As Form
-
-
For Each frm In Application.Forms
-
If frm.Caption = "8" Then 'Laura Callahan
-
frm.SetFocus
-
End If
-
Next
-
- 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:
-
Caption Handle
-
5 1902222
-
Caption Handle
-
8 460740
-
Caption Handle
-
1 460732
-
Caption Handle
-
9 526246
-
Caption Handle
-
2 264282
-
Caption Handle
-
7 329800
-
Caption Handle
-
3 133248
-
Caption Handle
-
4 133292
-
Caption Handle
-
6 133336
-
- Notice that the Form Captions and Handles are Unique.
- Hope that this eliminated some of the confusion, and that I didn't make things worse for you (LOL)
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
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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.
...
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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,...
|
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...
|
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...
| | |