Form hopping

G

Gordon

I have a form (frmVocalArrangments) with a button that when pressed
opens another form (frmDiscs) in data add mode - but keeps
frmVocalArrangments open.

On frmDiscs, when the new record is added, I have a "Return" button
that takes me back to frmVocalArrangments with the code:
Private Sub cmdReturn_Click()
On Error GoTo cmdReturn_Click

If Me.OpenArgs = "frmVocalArrangements" Then
DoCmd.OpenForm "frmVocalArrangements"
CloseForm Me [Note: closeform is a standard module I have to close
the current form]
Exit Sub
Else
DoCmd.OpenForm "frmFormsMenu"
CloseForm Me
End If
Exit_cmdReturn_Click:
Exit Sub

cmdReturn_Click:
MsgBox Error$
Resume Exit_cmdReturn_Click

End Sub

So far so good. frmDiscs closes and I am returned to
frmVocalArrangements

However, on frmDiscs I also have a "Cancel" button to undo any changes
with the code:

Private Sub cmdCancel_Click()
On Error GoTo cmdCancel_Err

SendKeys "{Esc}", True
Me.Undo
DoCmd.ShowAllRecords
cmdCancel_Exit:
Exit Sub

cmdCancel_Err:
MsgBox Error$
Resume cmdCancel_Exit
End Sub

If I use this button and then press the Return button, I am returned
to thewrong form (frmFormsMenu) - with frmVocalArrangements still open
in the background.

I have tried all combinations of code on these two buttons but just
cannot get them both to work the way I want.

Where am I going wrong?

Gordon
 
G

Gordon

I have a form (frmVocalArrangments) with a button that when pressed
opens another form (frmDiscs) in data add mode - but keeps
frmVocalArrangments open.

On frmDiscs, when the new record is added, I have a "Return" button
that takes me back to frmVocalArrangments with the code:
Private Sub cmdReturn_Click()
On Error GoTo cmdReturn_Click

If Me.OpenArgs = "frmVocalArrangements" Then
DoCmd.OpenForm "frmVocalArrangements"
CloseForm Me    [Note: closeform is a standard module I have to close
the current form]
Exit Sub
Else
DoCmd.OpenForm "frmFormsMenu"
CloseForm Me
End If
Exit_cmdReturn_Click:
    Exit Sub

cmdReturn_Click:
    MsgBox Error$
    Resume Exit_cmdReturn_Click

End Sub

So far so good. frmDiscs closes and I am returned to
frmVocalArrangements

However, on frmDiscs I also have a "Cancel" button to undo any changes
with the code:

Private Sub cmdCancel_Click()
On Error GoTo cmdCancel_Err

    SendKeys "{Esc}", True
    Me.Undo
    DoCmd.ShowAllRecords
cmdCancel_Exit:
    Exit Sub

cmdCancel_Err:
    MsgBox Error$
    Resume cmdCancel_Exit
End Sub

If I use this button and then press the Return button, I am returned
to thewrong form (frmFormsMenu) - with frmVocalArrangements still open
in the background.

I have tried all combinations of code on these two buttons but just
cannot get them both to work the way I want.

Where am I going wrong?

Gordon

Answering my own question. I found the problem - In the on close
event of the frmDiscs I had some more code that closed the current
form and opened the frmFormsMenu.
 

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

Top