Due to the amount of data I'm opening on a single form, I must close forms before opening up the next form. The below code appears to require the form to be open, just not visible.
Does someone have a solution that captures the previous form, stores it in memory and makes it available from the active form to be used to return to the previous form?
Does someone have a solution that captures the previous form, stores it in memory and makes it available from the active form to be used to return to the previous form?
Code:
Option Compare Database
Option Explicit
'https://bytes.com/topic/access/answers/939693-access-return-previous-form
'This code determines the active form (with the fairly reliable assumption
'that this will be the same as the form that called it) when the Form_Open()
'procedure is run. It can play tricks when the form is opened from the database
'window, and maybe in other scenarios I haven't considered, but is otherwise
'pretty reliable.
Dim frmPrevious As Form
Private Sub Form_Open(Cancel as Integer)
Set frmPrevious=Screen.ActiveForm
frmPrevious.Visible=False
End Sub
Private Sub Form_Close()
frmPrevious.Visible=True
frmPrevious.setfocus
End Sub