history

jamesT

Registered User.
Local time
Today, 11:44
Joined
Mar 5, 2003
Messages
16
I have two forms

1) Current Projects
2) Completed Projects

Both e of these form access the third form

3) Project details

When I press the close button on the thrid form how do i make the user go back to the form they (either 1 or 2) they came from


Thanks
 
Create a public variable within a module:

Public strOpenedForm As String


And then assign the name of the form that they were on when they opened the Details form to the variable in the on open event of the form they open.

Then in the on close event of that form use this:

If strOpenedForm <> "" then
Docmd.OpenForm strOpenedForm
Else
[put whatever code here as a safety net if the variable wasn't assigned for some reason] or you can use an on error goto ... error handler in case there is no string assigned to the variable.

End If


This should work for you.
 
Thanks for the help

I put this into a module

Public strOpenedForm As String


Then in the on Opend event of the form they are in I put
strOpenedForm = Me.form

But I get a type mis match error here not sure why
 
An even easier method would be to use the OpenArgs property.

When opening a form, you just pass the current form's name into this property.

i.e

Code:
DoCmd.OpenForm "frmFormC", acNormal, , , , , Me.Name

Me.Name is the OpenArgs (basically the name of the form)

When on the form and wanting to return to the calling form, simple use:

Code:
DoCmd.OpenForm Me.OpenArgs, acNormal



* As an aside, the reason you got an error with this line: strOpenedForm = Me.form is because you were trying to assign a form to a string variable - since Me is the form, you could have used: strOpenedForm = Me.Name
 

Users who are viewing this thread

Back
Top Bottom