Results 1 to 8 of 8
  1. #1
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Minimise & maximise database (2000)

    Hi,

    I have a process in an Access database that exports data to another application. During this process, Access freezes, which is fine. But is there a way to have the Database minimise when the process is started, and then return to its original size after completion. Mainly as my forms prevent the user from exiting unless using the exit command button.

    So for instance:

    MsgBox "This database will now minimise whilst this operation is being performed", vbOKOnly & vbexclamation, "Note:"

    Minimise database here.

    Process begins.

    Process ends.

    Then reopen database.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Minimise & maximise database (2000)

    Create a new module and copy the following code into it:

    Private Type Rect
    X1 As Long
    Y1 As Long
    X2 As Long
    Y2 As Long
    End Type

    Private Type PointAPI
    x As Long
    y As Long
    End Type

    Private Type WindowPlacement
    Length As Long
    Flags As Long
    showCmd As Long
    ptMinPosition As PointAPI
    ptMaxPosition As PointAPI
    rcNormalPosition As Rect
    End Type

    Private Declare Function GetWindowPlacement Lib "user32" _
    (ByVal hWnd As Long, lpWndPl As WindowPlacement) As Long

    Private Declare Function SetWindowPlacement Lib "user32" _
    (ByVal hWnd As Long, lpWndPl As WindowPlacement) As Long

    Public Const SW_Maximize = 3
    Public Const SW_Minimize = 6
    Public Const SW_Restore = 9
    Public Const SW_ShowNormal = 1

    Public Sub AccessWindow(sw As Long)
    Dim wp As WindowPlacement
    wp.Length = Len(wp)
    GetWindowPlacement Application.hWndAccessApp, wp
    wp.showCmd = sw
    SetWindowPlacement Application.hWndAccessApp, wp
    End Sub

    Use it like this in your own code:

    MsgBox "This database will now minimise whilst this operation is being performed", vbExclamation, "Note:"
    AccessWindow SW_Minimize
    'Process begins.
    '...
    'Process ends.
    AccessWindow SW_Maximize

  3. #3
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Minimise & maximise database (2000)

    Wow, thanks Hans.

    And heres me in my naivety hoping it was going to be as easy as DoCmd.Minimise!!!!

    Thanks!

  4. #4
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Minimise & maximise database (2000)

    "Whilst"! Shouldn't you also have a "forsooth" in there? <img src=/S/wink.gif border=0 alt=wink width=15 height=15>
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  5. #5
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Minimise & maximise database (2000)

    Yes, I'm going hunting with the hounds later.... <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>

  6. #6
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Minimise & maximise database (2000)

    I thought this was working okay! But........
    I've created the module and used the coding as specified but the coding on the control button (on a previous database that you've helped me with) is this:

    Excessively long code fragment moved to attachment by HansV

    But this freezes the database entirely, although it does minimise! Have I place the AccessWindow SW_Maximize/Minimize in the correct place?

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Minimise & maximise database (2000)

    Could it be that Access is maximized again, but behind another window? You could check this by minimizing all other open applications.

    I would place the instruction to maximize Access in the ExitHandler part, just above Exit Sub, so that Access gets maximized (at least, it should) even if an error occurred.

  8. #8
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Minimise & maximise database (2000)

    Seems to work fine now.
    The problem seemed to be that the system had frozen when creating the excel document. For some reason when I tried to open an existing unrelated excel document, this unfroze the process.
    It now works in a matter of seconds, as opposed to minutes......peculiar.......... <img src=/S/notmyfault.gif border=0 alt=notmyfault width=15 height=15>

Posting Permissions

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