I am trying to get a child form to changes its record source based on criteria the user selects from the parent form. the below does create the record select string correctly, but I cannot get it to recognize the child form. I have commented out the requery as it errors our when it hits the recordsource setting.
Private Sub FilterForm(strFilter As String)
On Error GoTo ErrorHandler
Dim strSelect As String
Dim dteStartDate As Date
Dim dteEndDate As Date
Dim strAccountID As String
Dim strWhere As String
Dim intLength As Integer
strSelect = "SELECT * FROM tblAccountTransactions"
If Not IsNull(Me.txtStartDate) And Not IsNull(Me.txtEndDate) Then
strWhere = "(tblAccountTransactions.TransactionDate Bewteen #" & Me.txtStartDate & "# AND #" & Me.txtEndDate & "#) AND "
ElseIf Not IsNull(Me.txtStartDate) And IsNull(Me.txtEndDate) Then
strWhere = strWhere & " tblAccountTransactions.TransactionDate >= #" & Me.txtStartDate & "# AND "
End If
If Not IsNull(Me.cboAccount) Then
strWhere = strWhere & " tblAccountTransactions.AccountId = '" & Me.cboAccount.Column(0) & "' AND "
End If
intLength = Len(strWhere) - 5
strWhere = Left(strWhere, intLength)
If strFilter = "Filter" Then
Forms!frmTransactions!sfrmaccountTransactions.Form.RecordSource = strSelect & " WHERE " & strWhere
' Me.sfrmaccountTransactions.Forms.Requery
ElseIf strFilter = "Clear Filter" Then
Forms!frmTransactions!sfrmaccountTransactions.Form.RecordSource = strSelect
' Me!sfrmaccountTransactions.Form.Requery
End If
Exit_ErrorHandler:
Exit Sub
ErrorHandler:
MsgBox "Error Number: " & Err.Number & " Description: " & Err.Description
Resume Exit_ErrorHandler
End Sub
ASKER