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

Window priority above other apps.

P: 74
How do i get my access 2003 Windows to always appear above all other applications running?
Mar 15 '07 #1
Share this Question
Share on Google+
12 Replies


100+
P: 1,646
How do i get my access 2003 Windows to always appear above all other applications running?
Hi. I have moved your thread to the access forum
Mar 15 '07 #2

P: 74
Do you have any idea on this subject?
Mar 15 '07 #3

ADezii
Expert 5K+
P: 8,628
How do i get my access 2003 Windows to always appear above all other applications running?
I should have the answer for you shortly. It involves an API call and the Handle to the Main Access Window. Please be patient.
Mar 15 '07 #4

ADezii
Expert 5K+
P: 8,628
How do i get my access 2003 Windows to always appear above all other applications running?
As previously promised, the following code will make the 'Main Access Window' always appear above all other running applications. First the API Declaration:
Expand|Select|Wrap|Line Numbers
  1. Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
NOTE: Use extreme caution whenever using API Calls and always backup your Database prior to experimenting. The slightest Syntax or other Error could cause a General Protection Fault. This code has been tested on Access 2003 and does, in fact, work:
Now the code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2.   Dim wFlags As Long, lngX As Long
  3.  
  4.   wFlags = &H2 Or &H1 Or &H40 Or &H10
  5.   lngX = SetWindowPos(Application.hWndAccessApp, -1, 0, 0, 0, 0, wFlags)
  6. End Sub
Mar 15 '07 #5

P: 74
I get an error message after opening the form saying "Compile error: Expected variable or procedure, not module" it then opens VBA and highlites "SetWindowPos" in the private sub on the form. Any ideas?
Mar 16 '07 #6

P: 74
Take that back I got it to work, However the only draw back on this is when an error message appears behind the window you cant get to it.
Mar 16 '07 #7

ADezii
Expert 5K+
P: 8,628
Take that back I got it to work, However the only draw back on this is when an error message appears behind the window you cant get to it.
That is a considerable Trade Off.
Mar 17 '07 #8

P: 74
That is a considerable Trade Off.
So check it out i am using this code in a command click button now. Sometimes i want it to remain above other apps other times i don't so far i have this

Private Sub Pri_Click_Click()
If Me.Pri_Click = True Then
Dim wFlags As Long, lngX As Long
wFlags = &H2 Or &H1 Or &H40 Or &H10
lngX = SetWindowPos(Application.hWndAccessApp, -1, 0, 0, 0, 0, wFlags)
If Me.Pri_Click = False Then GoTo Ext_Pri
End If
Ext_Pri:
End Sub

Do you happen to know the code to take the Window Priority away?
Any help would be amazing, thanks in advance.
Sep 12 '07 #9

ADezii
Expert 5K+
P: 8,628
So check it out i am using this code in a command click button now. Sometimes i want it to remain above other apps other times i don't so far i have this

Private Sub Pri_Click_Click()
If Me.Pri_Click = True Then
Dim wFlags As Long, lngX As Long
wFlags = &H2 Or &H1 Or &H40 Or &H10
lngX = SetWindowPos(Application.hWndAccessApp, -1, 0, 0, 0, 0, wFlags)
If Me.Pri_Click = False Then GoTo Ext_Pri
End If
Ext_Pri:
End Sub

Do you happen to know the code to take the Window Priority away?
Any help would be amazing, thanks in advance.
Try the following code segment to turn OFF the TopMost Attribute:
Expand|Select|Wrap|Line Numbers
  1. Dim wFlags As Long, lngX As Long
  2. wFlags = &H10 Or &H40
  3. lngX = SetWindowPos(Application.hWndAccessApp, -2, 0, 0, 0, 0, wFlags)
Sep 12 '07 #10

P: 74
That code take the window minimizes it and move it into the tope left corner of my screen.
Sep 13 '07 #11

P: 74
Dim wFlags As Long, lngX As Long
wFlags = &H10 Or &H40
lngX = SetWindowPos(Application.hWndAccessApp, -2, 0, 0, 0, 0, wFlags)

I figured out that the H10 and H40 was the cause of the screen movement, I changed them to 2 and 1 like in the previouse code but kept the -2. this works great.
Sep 13 '07 #12

ADezii
Expert 5K+
P: 8,628
Dim wFlags As Long, lngX As Long
wFlags = &H10 Or &H40
lngX = SetWindowPos(Application.hWndAccessApp, -2, 0, 0, 0, 0, wFlags)

I figured out that the H10 and H40 was the cause of the screen movement, I changed them to 2 and 1 like in the previouse code but kept the -2. this works great.
Glad you figured it out.
Sep 13 '07 #13

Post your reply

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