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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Previous form

Status
Not open for further replies.

MikeCDPQ

Technical User
Sep 11, 2003
173
CA
I am looking for a way to store a form's name when it gets the focus so that if I move the focus to another form, it knows where it was accessed from.

For testing purposes I am putting a msgbox on the subsequent forms to show me the name of the form that I just came from. I am dealing with modal forms and the got or lost focus behaves differently in those cases I believe.

what I have for now on form ACTIVATE:

Option Compare Database
Public PreviousScreen As Form
Public PreviousForm
Function RememberMe()

Set PreviousScreen = Screen.ActiveForm
PreviousForm = PreviousScreen.Name


End Function

Then when I open another form (for testing purposes) I have:

Function WhereFrom()

MsgBox PreviousForm & " just Lost the focus"

End Function


This does not work. It gives me the name of the form that I am accessing.

I guess I just don't know what to use: Open, Load, Activate.

I feel I am close but there's that certain Je ne sais quoi :) that's missing.

Thanks for any suggestion.

Mike
 
Try the DeActivate event to store the form name.

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

You could use OpenArgs to pass the form name to your form.

e.g
Code:
Docmd.OpenForm "MyForm",acNormal,,,,acDialog,Me.Name
Then in MyForm, just access Me.OpenArgs which will contain the name of the previous form.

Hope This Helps
 
Thank you both very much for your suggestions.

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top