Switching Windows

  • Thread starter Thread starter PeterM
  • Start date Start date
P

PeterM

I'm running Access 2003 using an Access 2000 file
format.

Program A minimizes itself and then calls program B
(opened as modal). Program B closes and I can't figure
out how to activate Program A. Program A has an activate
event where the Program A is maximized. I just can't
figure out how to activate Program A from Program B or
how to maximize Program A from Program B before Program B
closes.

Please Help!
 
Well, I suppose the first part is why minimize..program a...

If you open program b...and the users closes that program...you will be
right back to program "a"..(ms-access...right?)

However, there are some code things you an use.

Also, you make no mention of how the 2nd program is being launched..and what
kind of program it is? (it makes it VERY VERY hard to come up with any kind
of answer).

If it is a standard windows program..and you are using automaton..then
usually:

YourComObjectApplication.Activate
YourComObjectApplication.WindowState = 0 'wdWindowStateRestore

The above usually does the trick. (change the above to whatever automation
object you using).

Also...you can also use AppActivate

So:

AppActivate "Microsoft Word"

AppActivate will move the focus to the given running application..but NOT
necessary max the application. (so, that is why I am suggesting you don't
min the application in the first place).

You can also use a api to bring up the window also..check out:

http://www.mvps.org/access/api/api0019.htm

So, depending on how you launch the 2nd program..one of the solutions above
should do the trick...

If you want to see the first solution in action...you can try my access to
word automation example..as I do in that application max the window via
code.....(and in windows xp...that often causes a flashing bar on the bottom
of the screen...and forces the *user* to click to let the program max).

You can give the word merge example it a try at:
http://www.attcanada.net/~kallal.msn/msaccess/msaccess.html
 
program A calles program B by using the DoCmd.OpenForm
command.

Program A Code for launching Program B
-----------------------------------------
Dim stDocName As String
Dim stLinkCriteria As String

DoCmd.Minimize
stDocName = "engagements_CDMi"
DoCmd.OpenForm stDocName, , , stLinkCriteria
 
program A calles program B by using the DoCmd.OpenForm
command.

My sorry...your are talking about loading a form..not another application,
or another program. We don't usually refer to loading another form as
"loading another program"

We load a program like word, or load a program like Excel.

In ms-access, when a form "a" loads form "b"...that is simply another form
being loaded..and has no relation to loading another program.

So, I totally miss-understood you. (this also likely explains why people
were having difficult answering your question).

So, I can now assume not:
Program A Code for launching Program B

But...simply form a loads a form b.....
Program B has the following code in the Activate event

In form "B" close event...you can use:

Forms!form1.SetFocus
DoCmd.Restore

You can also use:
DoCmd.Maximize in place of the above restore.

In addition...you might want to use the forms visible property...and simply
"hide" it.....and thus not use min/max....

Further, if you make the form "b" model..then the user HAS to close the form
B to get back to form "a". For this reason...a large portion of my forms are
model..as that forces the user to go back exactly in the reverse direction
that a series of forms were opened. Thus, using model means I don't have to
worry..or write a bunch of code to min/max forms as my application winds its
way deep into a series of forms.
 
THANK YOU!

Sorry for the confusion. I'm kinda new to Access and VBA
and I will work on being more accurate when using
terminology. Your suggestion worked great. I was trying
to SETFOCUS
 
PeterM said:
THANK YOU!

Sorry for the confusion. I'm kinda new to Access and VBA
and I will work on being more accurate when using
terminology. Your suggestion worked great. I was trying
to SETFOCUS

You are most welcome!. I should also add that I take some blame..since your
SUBJECT line was in fact quite good..and was asking about switching windows.

Anyway ...not a big deal...and we did more towards solution...and that is
great!
 
Back
Top