Question : Get form data to subform

Because secrecy is very important in a DB of employee-information I have decided to only connect to a MS SQL-DB using code. Thereby stopping the possibility to open Access with shift and seeing the content of the tables. The users of course need access to the table so they can use the DB.
My problem comes when trying to filter sub forms. I cannot get the employeeID information from the mainform. I cannot use linked fields with unbound forms!
Other fresh solutions are also welcomed!

The code breaks here: If Forms![frmEmployeeMain]![EmployeeID] <> "" Then
Code Snippet:
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

Answer : Get form data to subform

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
Random Solutions  
 
programming4us programming4us