tempcars to remember a closed for to reopen later

is it possible to use tempvars to remember a form closing and use that to reopen the form later
Ernest GroggSecurity Management InfoSecAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

If you want to simply log the fact that a form closed, do it in the form's unload event.  You can then check the tempvar to see if it was set.
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You can use TempVars for any number of things - they're really just an in-memory set of variables that can be globally referenced.

But you'd have to give more information about what you want to do. Opening a form is easy (just use DoCmd.OpenForm), but I assume you want to do something more - like open a form back to a specific record, or with a specific subset of records, perhaps.
Dale FyeOwner, Developing Solutions LLCCommented:
or, another reason for logging a form close operation might be to keep a stack of forms that were opened, and in what order.  If that is the case, you might want to consider a collection.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Ernest GroggSecurity Management InfoSecAuthor Commented:
What I want to do is use a search form in several areas on my forms that go from section to section.

I want to reopen the last form when I close the search form.  So if tge search form was opened in one area it will reopen in that area.

Say frmOptions opens frmSearch, so closing frmSearch reopens from prions again

But if frmSearch was opened from frmOptions2 then when frmSearch closes it reopens frmOptions2

No matter where frmSearch opens the last form is reopened.
Dale FyeOwner, Developing Solutions LLCCommented:
Usually, I don't close a form that calls my search form, I just popup the search form on top of the other form.

However, another way to handle this is to pass the searchform the name of the form that called it, during the OpenForm method.  
docmd.OpenForm "frmSearch", acNormal, , , , , me.name
docmd.close acform

Open in new window

Then use the Form_Close event of the search form to either open or set the focus to the form that opened it.  This would look something like:
Private Sub Form_Close

    is currentproject.allforms(me.OpenArgs).isloaded then
        Forms(me.OpenArgs).visible = true
        docmd.openform me.OpenArgs, acviewnormal

End Sub

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
I don't close forms either but I do hide them so that the user rarely ever sees more than one open form at a time.  I use the OpenArgs to reopen the calling form when the called form closes.  This allows unlimited nesting.  The one thing you need to be conscious of is reusing a form in an alternate path.  Since no history is actually kept, you can only follow one path back to the beginning.
Private Sub Form_Close()
On Error GoTo ErrProc
    If frm.Dirty Then
        DoCmd.RunCommand acCmdSaveRecord
    End If
    If IsNull(frm.OpenArgs) Then
        DoCmd.OpenForm "Switchboard"
        DoCmd.OpenForm frm.OpenArgs
    End If
    Exit Sub
    Select Case Err.Number
        Case 2102   'bad open args form name
            Resume ExitProc
        Case 2455   'happens for A2007 when unbound form references the Dirty property
            Resume Next
        Case Else
            MsgBox Err.Number & "--" & Err.Description
            Resume ExitProc
    End Select
End Sub

Open in new window

Ernest GroggSecurity Management InfoSecAuthor Commented:
thank you so much!
Ernest GroggSecurity Management InfoSecAuthor Commented:
I am using this search form for multiple uses and changes from the search criteria chosen so that only certain forms open based on that search, like editing a customer, or order, or various data info.

I only need that form to remember the previous,  both work out great, just didn't see Pat's until after.. sorry
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.