How do you write a sub procedure that, when you pass a form's name or a form object as the parameter, it checks to see if the form is loaded, then requery its underlying subform?
This is what I was trying to do, hard-coded:
Ultimately, I'd like to come up with a sub procedure like this:
But of course, this code doesn't work. It'll do if I were just requerying the main form, but not the subform. I don't know how to use a variable in place of the subform.
Any ideas?
This is what I was trying to do, hard-coded:
Code:
Forms!frmMain1.subForm1.Form.Requery
Code:
Sub UpdateForm(frm As String)
Dim subfrm As String
subfrm = DLookUp("SubFormName","FormsLookup","MainForm='" & frm & "'")
If IsFormLoaded(frm) Then Forms(frm).subfrm.Form.Requery
End Sub
UpdateForm("frmMain1")
Any ideas?