From: Cevin on
I'm trying to build a module that when a user closes a form (say form 2), it
will take them back to the form that called form 2 via a close button on form
2. I want it to work on all my forms, so that no matter what form gets
closed, it will take them back to the original form then close form 2.
I set up two public string variables in the forms. One that contains the
caller form and one that contains the current form. I figgured that when I
pass both of those variables to the module, it will move to the caller form
then close the current form.
It maintains the variables thru the passing from the form to the module, but
when it runs it gives me a 424 Object required error.
How can I use the variables to return to the calling form and then close the
current form?

Thank you in advance for your assistance.
Cevin
From: Daryl S on
Cevin -

The normal way to do this is to pass in the name of the calling form as the
OpenArgs parameter to the second form. Then when the second form closes, use
the OpenArgs to know which form to open back up. Look up help on OpenArgs
for this.

--
Daryl S


"Cevin" wrote:

> I'm trying to build a module that when a user closes a form (say form 2), it
> will take them back to the form that called form 2 via a close button on form
> 2. I want it to work on all my forms, so that no matter what form gets
> closed, it will take them back to the original form then close form 2.
> I set up two public string variables in the forms. One that contains the
> caller form and one that contains the current form. I figgured that when I
> pass both of those variables to the module, it will move to the caller form
> then close the current form.
> It maintains the variables thru the passing from the form to the module, but
> when it runs it gives me a 424 Object required error.
> How can I use the variables to return to the calling form and then close the
> current form?
>
> Thank you in advance for your assistance.
> Cevin
From: Albert D. Kallal on
While we wait for some others to perhaps come up with some code examples,
I'm going to suggest that you solve this problem without any code at all.

What I do in my applications is simply set the form's property as modal,
what this means then that if you have one form and it launches another form,
the user must close the current form (just launched) to get back to the
previous calling form. They will be unable to get back to the previous form
until they close the existing form they're working on.

Because my applications are quite rich from a user interface point of view,
I tend to have quite a few forms, and therefore users can get lost if I
don't control their pathway that they go down when they launch form after
form.

So it's very common to want to control and make sure the user returns from
the calling form. If you set " modal" in the other tab of the property sheet
for a form correctly, then you'll not need any code at all.

Hence, a form as modal, then the only choice the user has is to launch more
forms from that form, or close the current form to return back to the
previous calling form. Users will be unable to jump or side tracked or skip
out of the current form unless they close it. Keep in mind that modal forms
behave significantly different than that of dialog forms.

So perhaps in place of writing all that code, consider using the modal
property of the form to correctly control the form flow in your application:
that's exactly why that feature is available in Access.

I would say perhaps about 80 perhaps even 90% of all my forms are modal for
the above reason.

And once again, I stress don't confuse these modal forms with that of
dialogue forms.

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal(a)msn.com


From: Cevin on
Daryl & Albert, thank you for your response.

I can get the name of the first form to the second form using OpenArgs. The
problem I'm having is getting the first form visible and having the focus. I
can't get the OpenArgs variable to be recognized in the code line to switch
back to the first form.

I agree that there are many uses for a modal form, but not for every form in
the application I'm building.
I don't always want to bring the application to a halt when a form is open.
For instance, the user may be using a form to do some data entry which may
take 10 to 15 minutes to enter and verify the data before saving it to a
table. In that time say one of our road techs calls for a phone number for a
vendor. I'd like the user to be able to switch over to the applications
'switchboard', taking them to another form/report to look up the phone number
without having to lose the data entry info by closing a modal form. I
figgured that by keeping the calling form with the open form, if the user has
a couple forms open, it will always guide them back up the same path that a
particular form started from, and still let them be able to multi-task.

My ultimate goal (maybe a bit lofty) is have the application able to do many
things like above. Utilizing tabs the 'switchboard' tab would always be
available so the user could multi-task to look up a price, a phone number,
etc.
Although, as Albert said, I'd also like to sometimes use modal form(s) to
steer a user down a pathway for other tasks so they MUST complete the entire
path before ending (to maintain referential integrity).
If there is a way to do both modal forms and multitask ability, it would
certainly be helpful. Also if there is a better way than what I'm thinking,
I'd like to hear it.

Thanx again,
Cevin
From: BruceM via AccessMonster.com on
Please post the code. Specifically, how are you trying to reopen the first
form?

Cevin wrote:
>Daryl & Albert, thank you for your response.
>
>I can get the name of the first form to the second form using OpenArgs. The
>problem I'm having is getting the first form visible and having the focus. I
>can't get the OpenArgs variable to be recognized in the code line to switch
>back to the first form.
>
>I agree that there are many uses for a modal form, but not for every form in
>the application I'm building.
>I don't always want to bring the application to a halt when a form is open.
>For instance, the user may be using a form to do some data entry which may
>take 10 to 15 minutes to enter and verify the data before saving it to a
>table. In that time say one of our road techs calls for a phone number for a
>vendor. I'd like the user to be able to switch over to the applications
>'switchboard', taking them to another form/report to look up the phone number
>without having to lose the data entry info by closing a modal form. I
>figgured that by keeping the calling form with the open form, if the user has
>a couple forms open, it will always guide them back up the same path that a
>particular form started from, and still let them be able to multi-task.
>
>My ultimate goal (maybe a bit lofty) is have the application able to do many
>things like above. Utilizing tabs the 'switchboard' tab would always be
>available so the user could multi-task to look up a price, a phone number,
>etc.
>Although, as Albert said, I'd also like to sometimes use modal form(s) to
>steer a user down a pathway for other tasks so they MUST complete the entire
>path before ending (to maintain referential integrity).
>If there is a way to do both modal forms and multitask ability, it would
>certainly be helpful. Also if there is a better way than what I'm thinking,
>I'd like to hear it.
>
>Thanx again,
>Cevin

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/201003/1