Results 1 to 8 of 8

Thread: Cascading forms

  1. #1
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10

    Unanswered: Cascading forms

    Background:
    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
    Code:
    'details form collection
    Public clnDetails             As New Collection
    
    'Variable to hold unique_identifier
    Public uniqueIdentifier       As String
    
    
    
    Function OpenADetailsForm()
    
    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)
    
    ErrorHandler:
        Set frm = Nothing
        If err <> 0 Then
            CloseAllDetails
            ErrorHandler "OpenADetailsForm", err.Number, err.Description
        End If
     
    End Function
    Here's the event on the search form
    Code:
    Private Sub resultList_DblClick(Cancel As Integer)
    
            uniqueIdentifier = Me.resultList.Value
            OpenADetailsForm
    
    End Sub
    Here's the close event on the details form
    Code:
    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
                Exit For
            End If
        Next
    
        'Deassign the object and remove from collection.
        Set obj = Nothing
        If blnRemove Then
            clnDetails.Remove CStr(Me.Hwnd)
        End If
    Any ideas chaps and chapettes?
    George
    Home | Blog

  2. #2
    Join Date
    Feb 2007
    Posts
    348
    George,

    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?

  3. #3
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    I'm sure I've shown you this before.... You just don't listen
    http://www.peterssoftware.com/winmanip.htm

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    In fact - what about the "Hello George" application I wrote for you? That was soup herb - (almost) exactly what you are after.

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Nice idea Starkmann - except each instance of the form is opened from one main form; which will have, in effect, a constant position.

    Poots - I remember those now; unfortunately my work PC was re-imaged and they were one of the things I did not save! I'll have a looky when I get in tonight.

    Cheers guys
    George
    Home | Blog

  6. #6
    Join Date
    Feb 2007
    Posts
    348
    on my idea, so pass the window location back to the main form as each one opens.

    Although, what ever pootle has, I'll be it's cooler.
    Off to read that one.

  7. #7
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by georgev
    Poots - I remember those now; unfortunately my work PC was re-imaged and they were one of the things I did not save! I'll have a looky when I get in tonight.
    You did not archive "Hello George?"

  8. #8
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    No...
    Because I have that on my home PC

    However if memory serves, that used DoCmd.Resize method along with random numbers...
    Gosh it was pretty... Must look into how you got th background color to change
    George
    Home | Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •