hii all dears
based on this example i build a seperated filter form (without record source data) , to filter another form , but it does not filter that another form .
i use this code :
based on this example i build a seperated filter form (without record source data) , to filter another form , but it does not filter that another form .
i use this code :
Code:
Dim strWhere As String 'The criteria string.
Dim lngLen As Long 'Length of the criteria string to append to.
Const conJetDate = "\#mm\/dd\/yyyy\#" 'The format expected for dates in a JET query string.
'Number field example. Do not add the extra quotes.
If Not IsNull(Me.CVZ) Then
strWhere = strWhere & "(Forms![MainFrm]![InsurCmpName] = " & Me.CVZ & ") AND "
End If
If Not IsNull(Me.DateXz) Then
strWhere = strWhere & "(format(Forms![MainFrm]![OrderDate],'m') = " & Me.DateXz & ") AND "
End If
'ByDatSearch
If Not IsNull(Me.ByDatSearch) Then
strWhere = strWhere & "(Forms![MainFrm]![OrderID] = " & Me.ByDatSearch & ") AND "
End If
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then 'Nah: there was nothing in the string.
MsgBox "No criteria", vbInformation, "Nothing to do."
Else 'Yep: there is something there, so remove the " AND " at the end.
strWhere = Left$(strWhere, lngLen)
'For debugging, remove the leading quote on the next line. Prints to Immediate Window (Ctrl+G).
'Debug.Print strWhere
'Finally, apply the string as the form's Filter.
Forms![MainFrm].Filter = strWhere
Forms![MainFrm].FilterOn = True
Forms![MainFrm].OrderBy = "[OrderID] ASC"
Forms![MainFrm].OrderByOn = True
End If