Accessing toolbars or menus from a Dialog form - not possible?

J

jchao123

Hello,

I've done the obligatory searching on google for an answer to this
question but without success.

I have a form (say switchboard) which opens various other forms. I
would like this switchboard to open another form, wait till that form
is closed, then continue execution (such as requerying the current form
with up to date data). Ok, I'm sure the experts already have the word
DIALOG popping in their heads and sure enough that works.

HOWEVER, opening a form in dialog mode I am advised is not the proper
way of opening general data entry forms.. but apart from bad form
design, it also means you can't use toolbars or if the form in dialog
mode opens up a query on the screen (read only mode) it opens in the
background as this form is in Dialog mode.

I know one solution would be to simulate a Dialog window by doing:

on error resume next
do while forms(sFrmName).name = sFrmName
doevents
loop
<continue>

This works, but it is processor intensive... and would you believe, my
customers laptop OVERHEATS when the processor is running at 99% for a
prolonged period of time...

Apart from telling the customer to buy a new laptop (!), is there any
other suggestions...
I'm considering looking in the API for a better DOEVENTS... or some
WAIT command to wait 1 second etc.... yuck but hey?

Thanks

Ju Chao
 
A

Albert D. Kallal

The solution, and one I used for years is to simply break-up your calling
code:

eg:

Sub Part1
. do some cool code preossing.

' now open form 2
docmd.OpenFrom "form2"

end usb

Public Sub Part2

' code to run AFTER form 2 closes goes here:


end sub

Now, in form2 close event, you go:

call forms!form1.Part2

You could do a bunch of looping as you have, or some strange API, but
really, the above is all you need.

And, if you need these routines to be somewhat more generic (since SEVERAL
forms might have to call form2, but run code *after* they return, then in
forms2 on-load event, go

set frmPrevous = screen.Activeform

(activeform is going to be the previous form UNTIL THE ON-LOAD EVENT IS
FINISHED.)

Now, in the forms on-close, we go:

frmPrevous.RunReturn

note that frmPrevous is a forms *module* level defined varable (that I
define for MOST of my forms, and thus I can access, or set the prevous forms
values and even public varables like:


frmPrevous.MenuOption = 5

or,

frmPrevous.Requery

etc. So, I always have the prevous form at my fingertips in code with the
above idea...

And, in form 1, we could/would define a public mehtoed of the form (public
functions become methoeds of a form).

Public Function RunReturn

' this code runs after the form2 is called.......
 
J

jchao123

Hmm.. some great ideas there to explore.. I guess you could also have
an optional parameter in the RunReturn function if you want to trigger
something different as well...

The main thing I wanted was that I was making the main form
Visible=false then Visible=true when it comes back from the called
form... I guess thats what the RunReturn function would do in this
case.

Cheers!

Dr Jue Chui
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top