I have a Main form (MainForm) with 2 subforms (SubForm1 and SubForm2) embedded inside. I wanted to add code into the MainForm_FormCurrent() procedure that would cause Subform2 to become invisible whenever MainForm advance to a record where there was no vlaue displayed in SubForm1. This is what I've come up with but it gives me an error. What am I doing wrong?
This is the coding I used for the Form_Current in MainForm:
Dim db As Database
Dim rs As Recordset
Dim strSQL As String
strSQL = Me![SubForm1].Form.RecordSource
Set db = CurrentDb()
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
If rs.BOF And rs.EOF Then
Me![SubForm2].Form.Visible = False
Else
Me![SubForm2].Form.Visible = True
End If
This is the coding I used for the Form_Current in MainForm:
Dim db As Database
Dim rs As Recordset
Dim strSQL As String
strSQL = Me![SubForm1].Form.RecordSource
Set db = CurrentDb()
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
If rs.BOF And rs.EOF Then
Me![SubForm2].Form.Visible = False
Else
Me![SubForm2].Form.Visible = True
End If