Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return to form conditionally from a form/subform

Status
Not open for further replies.

Rooski

Technical User
Sep 28, 2004
44
US
I am using Access 2000 and have been vainly scouring threads for the last day an a half in an attempt to find a solution to this problem. While some threads are close, I have not been able to successfully adapt those suggestions to my problem.

Scenario: I have two forms (Form1 and Form2) from which a user can come from directly to a common form consisting of a main form (MFormA) and a subform (SFormA). MFormA only displays data. SFormA adds data. When the user is done adding data to SFormA, I would like to return the user to the form from which he originally came (Form1 or Form2). I have a command button set up in SFormA for this purpose. Unfortunately, it doesn't take me back.

I have tried using OpenArgs where I pass Form1 or Form2 to MFormA. I interrogate the incoming me.OpenArgs value using a Form_Open subroutine in MFormA and store the value in a global-level string variable. Unfortunately, the SFormA never receives that information (it contains nulls). The mainform doesn't seem to communicate this information to the subform.

Has anyone developed a successful method for the above scenario?

Thanks, Rooski

 
And what about Form1 and Form2 opening MFormA as modal (acDialog) and thus getting the focus back when MFormA is closed ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi!

If you absolutely have to have Form1 and Form2 close when they call MFormA (and therefore cannot use the simplest solution which has already been suggested) then just get rid of the command button on the subform and, in the close event of MFormA, put the OpenForm command using the Me.OpenArgs.

If you really really want to use the command button then you can get to the information as follows:

DoCmd.OpenForm Me.Parent.OpenArgs.

hth


Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
PH and Jeff,

Thank you both for your replies.

First, I do close Form1 or Form2 (whichever the user started from) before opening MFormA to ensure the user can only operate from one screen at a time. Thus, PH's simple solution will not work according to Jeff.

Secondly, I am a beginner at MS Access but have a developer's background mostly in mainframes. I am developing an automated project logging system for a group of people who will not have code maintenance and enhancement support once I am finished. Thus, this group and I agreed to keep things a simple as possible (stay away from VB code as much as possible). Based on our comments, I can see things turning from simple to moderate to complex VB code. Consequently, I will continue developing the project without Form2 which will simplify things. Once the alpha version of the package is complete (approximately two weeks), I will return to the topic of this thread and experiment.

Thanks so much for your help,

Rooski.
 
the user can only operate from one screen at a time
This is PRECISELY what a modal form does ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PH!

That's just what I was going to say, but I see you beat me to it! I only gave the other options in case his requirements were aesthetic in nature! I rarely post after I see that you have answered since your replies are usually right on the money!

Keep up the good work.



Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top