By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,269 Members | 1,561 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,269 IT Pros & Developers. It's quick & easy.

acCmdAppMinimize causes form to lose focus on accde file

P: 63
I have an application that minimizes the Access application window and displays a pop-up modal form.

The Application window is minimized with this command in the form's Load event.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunCommand acCmdAppMinimize
When opening the file, the form/application retains focus and appears on top after the application window minimizes. But when I save it as an ACCDE file and open that, the form/application loses focus. If there are any other programs open, the form is hidden behind them all.

The only workaround I've found is to not use the above command, but instead to create a shortcut to the ACCDE file and in the Shortcut properties, set the "Run" property to "Minimized".

I'd like to find a solution within Access, if possible, because it's not always feasible to use the Shortcut workaround.

Any ideas would be much appreciated. Thanks!
May 20 '09 #1
Share this Question
Share on Google+
6 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
Try this and see if it makes any difference

Expand|Select|Wrap|Line Numbers
  1. Application.DoCmd.Minimize
May 22 '09 #2

ADezii
Expert 5K+
P: 8,638
@postman
You could always use the olde API to make sure the Application Window is Minized. It would only require a Function Declaration and the passing of the Application Handle (Application.hWndAccessApp) to the appropriate API Function.
May 23 '09 #3

P: 63
@msquared
I tried it, but this code minimizes the form, not the application window.
May 27 '09 #4

FishVal
Expert 2.5K+
P: 2,653
http://support.microsoft.com/kb/186431

And since form's hWnd is available via Form.Hwnd property you may drop FindWindow() function and use only BringWindowToTop().

Didn't test it but looks like it will work.

Regards,
Fish
May 27 '09 #5

P: 63
@ADezii
Thank you. That helped. Here is the API function I used at the top of the form's code module:

Expand|Select|Wrap|Line Numbers
  1. Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, _
  2.      ByVal nCmdShow As Long) As Long
Then in the Form's Load event, I put this line:
Expand|Select|Wrap|Line Numbers
  1. 'Minimize application.  "2" = minimized
  2. Call ShowWindow(Application.hWndAccessApp, 2)
Thanks for the help!

P.S. - I'm new to API calls. Are they pretty standard across the various iterations of Windows, or do they change? For example, would this call work on XP, but not on Vista or Windows 7?
May 27 '09 #6

ADezii
Expert 5K+
P: 8,638
@postman
To the best of my knowledge, they are fairly standardized across Windows Platforms except when dealing with earlier Versions. You must be extremely careful when calling them since there is no Buffering involved as with higher level Function Calls. They can crash Applications and even Lock Up the OS. I am referring to making sure you pass the proper number of Parameters, the Parameters are of the proper Data Types, some API Functions return results with Terminating Nulls, etc. Just research them as much as possible before you use them, and always work on a Copy of the Database at first.
May 27 '09 #7

Post your reply

Sign in to post your reply or Sign up for a free account.