Solved

Bring Form to Front

Posted on 2008-10-21
9
1,500 Views
Last Modified: 2013-11-28
I have a form that is launched from another form.  The first thing it does when it comes up is bring up a file browser so that the user can select an Excel workbook.  The user is then supposed to work with the launched form to interact with the Excel workbook.  However, in most cases the Excel workbook completely covers the launched form.  So the user never sees it to know that there is anything to do.

Is there a way to bring the launched form back on top of the Excel workbook?  I don't want my launched form to become a topmost form that always stays on top.  I just want it to pop to the front.
0
Comment
Question by:dastrw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 8

Expert Comment

by:Bradley Haynes
ID: 22770292
Use the form load event in VBA to load form on top.
0
 
LVL 2

Author Comment

by:dastrw
ID: 22770386
Could you give me some sample code?
0
 
LVL 7

Expert Comment

by:FER_G
ID: 22770657
You must use the "SetWindowPos API"

Public 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
Private Const HWND_ONTOP = -1
Private Const flags = SWP_NOMOVE Or SWP_NOSIZE

SetWindowPos frm1.hwnd, HWND_ONTOP, 0&, 0&, 0&, 0&, flags

So when you call the form (frm1) then, you call the "SetWindowPos API" and the form will allways be on top

FerG
Saludos
--
Ing. Fernando D. Giletta
San Fco. Cba. Argentina.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Author Comment

by:dastrw
ID: 22770698
I already saw that comment.  I don't want the window to always be on top.  That will be annoying for the user.  I just want the form to come to the front.
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 22771098
dastrw

Try using the AppActivate command:
http://msdn.microsoft.com/en-us/library/dyz95fhy(VS.80).aspx

dastrw
0
 
LVL 2

Author Closing Comment

by:dastrw
ID: 31508441
This is exactly what I needed.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22771608
;-)
0
 
LVL 2

Author Comment

by:dastrw
ID: 22771716
There is just a minor problem with the AppActivate method:  If I manually bring up the launched form then just it shows up in front of my Excel workbook.  If I use the AppActivate command then the entire Access application comes up in front of the Excel workbook.  It would be nice if I could get AppActivate to just show the launched form, but the launched form doesn't have its own individual menu name as far as Windows is concerned.  This is just nit-picking though.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22772703
Yeah,
This is probably about as simple as it gets without using complicated API Code.

Jeff
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question