I have a search form that shows results in a listbox. Users can view more detail about a record by double clicking one of the returned results.
I have implemented the following code to allow users to open multiple instances of the same form.
However, every instance of the form is opened in the same place (effectively covering up any previously opened instances).
I would like to change this so that they cascade, much like the Windows operating system does.
I've played with the DoCmd.Resize method but am not happy with the results and also I figure there must be a method that I'm missing!
Here's my code
Put the following in a module
'details form collection
Public clnDetails As New Collection
'Variable to hold unique_identifier
Public uniqueIdentifier As String
If isRunTime Then On Error GoTo ErrorHandler
Dim frm As Form_details
Dim i As Long
'Open a new instance, show it and add the caption
Set frm = New Form_details
frm.Visible = True
frm.Caption = frm.txtName.Value & " (" & frm.txtEmployeeNumber.Value & ")"
'Append it to our collection.
clnDetails.Add Item:=frm, Key:=CStr(frm.Hwnd)
Set frm = Nothing
If err <> 0 Then
ErrorHandler "OpenADetailsForm", err.Number, err.Description
Here's the event on the search form
Private Sub resultList_DblClick(Cancel As Integer)
uniqueIdentifier = Me.resultList.Value
Here's the close event on the details form
Dim obj As Object 'Object in clnClient
Dim blnRemove As Boolean 'Flag to remove it.
'Check if this instance is in the collection.
For Each obj In clnDetails
If obj.Hwnd = Me.Hwnd Then
blnRemove = True
'Deassign the object and remove from collection.
Set obj = Nothing
If blnRemove Then
I don't have code handy for you but you're usually better with that than I am anyway.
Each time they double click, could you have the first event be to grab the location of the form they just clicked on. Then add some number of pixels or quips or whatever and open the next form with this new number and the top/left locations?