I have a form on a subform on a subform. The Master and Child Links are null. Filter On Load is off, as is the filter, and the filter is blank.
The code below sets the recordsource property to a SQL string.
I can copy the contents of strSQL to a query and one record is displayed. The DCount always returns the expected count of records. But the form recordset appears to be empty. (The function that calls FilterDuplicates use .bof, .eof and .RecordCount .bof and .eof are always true, .RecordCount is zero. I've tried code that has worked a 1000 places before for the testing.)
What am I missing?
The code below sets the recordsource property to a SQL string.
I can copy the contents of strSQL to a query and one record is displayed. The DCount always returns the expected count of records. But the form recordset appears to be empty. (The function that calls FilterDuplicates use .bof, .eof and .RecordCount .bof and .eof are always true, .RecordCount is zero. I've tried code that has worked a 1000 places before for the testing.)
What am I missing?
Code:
Private Function FilterDuplicates(eMatchBy As enuMatchBy) As Long
Dim strFilter As String
Dim strSQL As String
Dim lngID As Long
If HasParent(Me) Then
lngID = Nz(Parent.ImportContactMatchingID, 0)
strFilter = MatchFilter(eMatchBy, lngID) ' Build the filter based. eMatchBy is an enum that defines a set of matching options.
' strFilter is typically something like "FedTaxID ='xxx-xx-xxxx'" at this point.
strFilter = strFilter & " AND ImportContactMatchingID <> " & CStr(lngID) ' Filters out the record we are testing for match/duplicate.
strSQL = "SELECT * FROM ImportContactMatching WHERE " & strFilter
Me.RecordSource = strSQL
Me.Requery ' Shouldn't need this, as setting the Record Source will force a requery, but I'm trying everything I can think of.
' Me.Filter = vbNullString ' Originally I just set the filter, but I had the same problem. So I tried setting the recordsource. (Previous line)
' Me.FilterOn = False
Debug.Print Me.Name, Me.Recordset.BOF, Me.Recordset.EOF, Me.RecordSource, DCount("ImportContactMatchingID", "ImportContactMatching", strFilter)
FilterDuplicates = DCount("ImportContactMatchingID", "ImportContactMatching", strFilter)
Else
FilterDuplicates = 0
End If
End Function