1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
Private Sub Form_Current() If Forms![frmEmployeeMain]![EmployeeID] <> "" Then Forms![frmEmployeeMain]![frmEmployeeS1].Form![frmSubChildren].Form.Filter = "[EmployeeID]=" & Forms![frmEmployeeMain]![EmployeeID] Forms![frmEmployeeMain]![frmEmployeeS1].Form![frmSubChildren].Form.FilterOn = True End If End Sub Private Sub Form_Load() Dim rs As New ADODB.Recordset, vEmployee As Integer Set rs = GetFormData("SELECT * FROM tblChildren;") Set Forms![frmEmployeeMain]![frmEmployeeS1].Form![frmSubChildren].Form.Recordset = rs Set rs = Nothing End Sub
I managed to get around the problem.
I defined a global variable which holds the employeeID.
I then cut out my code and put it in a global module. When triggering this code from my mainform current event I manage to get the correct data.
1: 2: 3: 4: 5: 6: 7: 8: 9:
Public Sub sSetRsChild(frm As Object) Dim rs As New ADODB.Recordset On Error Resume Next If vEmployee <> 0 Then 'vEmployee being the global variable Set rs = GetFormData("SELECT * FROM tblChilren WHERE [Employee]=" & vEmployee & ";") Set frm.Recordset = rs Set rs = Nothing End If End Sub