Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2008
    Posts
    3

    Unanswered: Form "Send to Back"

    Hi all. I've got a problem that I can't seem to figure out. I'm building an Access project and I need a little help. The exit button on the main form checks to make sure there are no other open forms before exiting the app. If there are other forms open, I want the user to have to close them (instead of me closing them via VBA). The problem is that the main form potentially blocks some of the other forms, and the way we have the main form set up, the user can't move it to get to the other forms. What I would like is for the main form to be "Sent to Back" when this event occurs. I know how to do it with controls, but I can't seem to find any reference to doing it with forms. Any help would be greatly appreciated.

    Thanks,
    John

  2. #2
    Join Date
    Nov 2008
    Posts
    3

    Never mind...got it

    Figured it out. Insted of sending the main form to the back, I just brought all of the other open forms to the front.

    Code:
    Private Sub cmdExit_Click()
    If Forms.Count > 1 Then
        Dim intx, intCount As Integer
        MsgBox "Please close all open forms before exiting the system.", vbOKOnly, "Close All Forms!"
        intCount = Forms.Count - 1
        For intx = intCount To 0 Step -1
            If Forms(intx).Name <> "frmMain" Then
                Forms(intx).SetFocus
            End If
        Next
        Exit Sub
    Else
        DoCmd.Close acForm, "frmMain", acSaveNo
    End If
    End Sub

  3. #3
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    You could also make the main form invisible (and then visible later).
    ie..

    Forms!MainFormName.visible = false

    Forms!MainFormName.visible = true

    If the main form is a modal form which causes problems for other forms (opening/closing), then setting the visible attribute will work for conflicts.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  4. #4
    Join Date
    Nov 2008
    Posts
    3
    Thanks...I'll try that out, as it's a bit simpler code than what I came up with.

  5. #5
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Curious... why not just close them down for the user?
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

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