Link to home
Start Free TrialLog in
Avatar of Rob4077
Rob4077Flag for Australia

asked on

Minimise form using compiled file

I am totally lost trying to understand why the following code works perfectly in an MDB file but not at all in an MDE file. The code is intended to minimize the popup. Originally I tried to build it into the load event of the form and later the timer event of the form but it won't work in either when the mdb is launched by another mdb so I decided to put a button on the popup that says minimize. I put the following declaration at the top of the form module:
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

I then put the following code in the button On Click event:
    Dim Minimise As Long
    Minimise = ShowWindow(hWndAccessApp, 2)

If I launch the mdb the popup opens. When I press the button the form minimizes. When I turn the mdb into an mde and launch it, the button does nothing.

Any suggestions?
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

Are you using the same environment for your mde as your mdb - same folder ?  same Access executable ?   same o/s?

Which Access version and which o/s please.
Avatar of Rob4077

ASKER

Hi Peter (if the 57 is your birth year then its the same as mine)

Yes, I am putting the MDE in the same folder as the MDB. It is using a BE and the way I've created it, an MDB will link to an MDB BE and an MDE will link to an MDE BE but the BE is in a sub-folder. In the opening code I re-link to the BE after compressing the BE.

I am using Access 2007 on a Windows 7 (Home Premium) laptop.
SOLUTION
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rob4077

ASKER

Thanks for checking it out for me. I will wait as you suggest.

The reason I use an mde for the BE is because I don't want users modifying my file.  I use a form that opens when the mde opens on a 5 second timer to tell them it's closing and then it closes. I know they can still link in and use the likes of ALTER TABLE statements to change the tables but it's harder.
1. First, I will ask why the standard Minimize button on the form does not work for you...?
If you set the Pop-up property to yes, the Min/max/restore buttons are still visible and working...

2. I don't have the code for the "ShowWindow" function, so I could not test this with Access 2007.

3. My other question would be... Why are you trying to minimize a Pop-up form?
You make a form "PopUp" so that it is the only window that has the focus.
Hence, I don't see a reason for it to ever be "Minimized"

So from where I stand, ...either turn off the "PopUp" property, and let this act as a normal form (that can be minimized using the standard Min/max/restore buttons)

...or leave the form as a Pop-up, and simply "close" it, ...as opposed to trying to "minimize" it.

(Again, the ability to minimize a form defeats the purpose of making it a pop-up form.)

JeffCoachman
Avatar of Rob4077

ASKER

Hi Jeff,

Thanks for your comments.  In answer to your questions:
<<1. First, I will ask why the standard Minimize button on the form does not work for you...? If you set the Pop-up property to yes, the Min/max/restore buttons are still visible and working...>>

I have set the Border Style to Dialog; Record Selectors to No; Navigation Buttons to No; Scroll Bars to Neither; Control Box to Yes; Close Button to Yes; Min Max Buttons to Min Enabled; and Popup to Yes. When I run the code the minimize button does not appear. If I change it to Popup = No, the Minimise button still does not appear.

<<2. I don't have the code for the "ShowWindow" function, so I could not test this with Access 2007.>>

All that is needed to make it work is: put the following declaration at the top of the form module:
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

Then put the following code in the button On Click event:
    Dim Minimise As Long
    Minimise = ShowWindow(hWndAccessApp, 2)

<<3. My other question would be... Why are you trying to minimize a Pop-up form?
You make a form "PopUp" so that it is the only window that has the focus. Hence, I don't see a reason for it to ever be "Minimized">>

The solution I have been asked to provide has two tasks. The first task is to give the user the ability to view parsed records. The second is to read emails at a fairly frequent rate, determine if any new emails have arrived that meet specific criteria and if they do, parse the data and drop the details into a database. I originally hoped to include both tasks into a single app but it takes too long to read emails in a timer event and that interferes with the user's ability to view details so I had to slit it into a two applications.

When launched the first app launches the second app. When the second app is launched a small popup appears that shows the app title, the time the emails were last read and, if it is reading, a message that says "Reading Emails...". I want the user to be able to minimise that small window to the task bar but I also want the user to be able to select that second app at any time to see the small status window.

I'm beginning to think that perhaps I should turn the second app into a VB Script that reads emails and loads data into the database. I can then enter a heartbeat indicator into the database and leave the VB Script hidden. I can then modify the first app to display the heartbeat indicator in its main window. What do you think?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rob4077

ASKER

I have left this running way too long. sorry. Thanks for your support. I will share the points.