Here's my current predicament:
I'm trying a new approach on handling the call of forms from another form and the return to the previous form. Instead of closing the forms and sending some parameters or using global variables to handle the return to the previous form once closed, I'm simply hiding the calling form from the called form, storing the previous form as a variable on each form and turning said previous form visible when closing the current form. That way I don't have to restore any information or filter being used on the form when the new one is called. Basically on each form:
Code:
Dim frmPrevio As Form
Private Sub Form_Open(Cancel As Integer)
Set frmPrevio = Screen.ActiveForm
frmPrevio.Visible = False
End Sub
Private Sub Form_Close()
frmPrevio.Visible = True
frmPrevio.SetFocus
End Sub
So far so good. Only some of the changes on those forms might alter information on some subforms of the previous form, so i need to requery those subforms. I did it from the form_close event of the called form (frmPrevio.subform_name.requery) and it worked alright, but those forms might be called from different forms and each of them has a different number of subforms with different names (or none at all). I have a few workarounds in mind, like requerying the whole form instead of the subforms (but that would make me have to restore the form to the current record, restore its filter and content on the filter boxes, and so on) or requerying the appropriate subforms depending on frmPrevio's name. But the ideal solution would be to requery the subforms on the main form's gotfocus event, since the close event of the forms sets the focus on the previous form, but the subforms are not requerying when I add Me.subfrm_name.requery on the gotfocus event of the main form. What am I missing? Is it possible to requery the subforms when setting the focus to the main form?
Thanks for your help