Cancel Button

I can currently access form "A" through form "B" or form "C".  I have a cancel button on form "A" which when clicked I would like it to return me to the form that I was using previously.  How can I code this cancel button to take me to the form I was previously on before going to form "A".  Any help would be appreciated.

 P.S.  I am using form show - form hide to do this.  
jakemailAsked:
Who is Participating?
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.

Erick37Commented:
In a MODULE put a global variable to hold the previous form as:

Public PrevFrm as Form

Then in the main form code:

Private Sub Command1_Click()
    Debug.Print PrevFrm.Name
End Sub

Private Sub Form_Deactivate()
    Set PrevFrm = Me
End Sub

Private Sub Form_Load()
    Set PrevFrm = Me
    Form2.Show
    Form3.Show
End Sub

And in each of the other forms use:

Private Sub Form_Deactivate()
    Set PrevFrm = Me
End Sub
0

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
KurvyCommented:

Instead of using a load event, create a Public Sub as follows
declare a form level variable
dim fLastForm as form

Public Sub Start(frmCall as form)

set flastform=frmcall
flastform.hide

**whatever code you need to start on your form**

me.show

End sub

in the unload event of the form
add the line

flastform.show
0
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
Visual Basic Classic

From novice to tech pro — start learning today.