Close Button back to Switchboard B

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I get the On_Click event to close the form and go back to the
Switchboard that called the form? Is there a way to capture "Who Called Me?"

I have tried the following and get an error (#2456).
Const cstrProcedure = "cmdbtnCloseForm_Click"
Const strcSwitchBoard = "Rotation Processing SwitchBoard"
Dim strDoc As String
Dim lngI As Long

On Error GoTo HandleError

For lngI = 0 To (Forms.Count - 1)
strDoc = Forms(lngI).Name
If strDoc <> strcSwitchBoard Then
DoCmd.Close acForm, strDoc
End If
Next
 
Hi Ed,

Quickly I wrote an MS 2003 Access app. It has frmOne, frmTwo, frmThree and
one module, modMain

In modMain I included the following code. This is just a declaration of a
form object:

Public G_frmCallingForm As Form

In frmOne I had the following code in the click event of a command button.
This sets the global declaration = Me (frmOne), then opens frmTwo


Set G_frmCallingForm = Me
DoCmd.OpenForm "frmTwo"

Finally, frmTwo has the following code in the click event of a command
button. This closes frmTwo, but gets frmOne just before it is actually
closed.:

DoCmd.Close
DoCmd.OpenForm G_frmCallingForm.Name

frmThree existed only to test. So I opened frmThree, then frmOne and clicked
the button on frmOne which opens frmTwo. Then I clicked frmThree, then
frmTwo. This put frmOne in the very back so I could see that when frmTwo
closes it actually gets back to frmOne. Of course it did.

I hope this helps you,
Denny
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top