filtering records ......

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Private Sub FindDate1_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[NTId] = " & Str(Me![FindDate1])
Me.Bookmark = rs.Bookmark
End Sub

Private Sub FilteredRecords1_AfterUpdate()
If FilteredRecords1 = 2 Then
Me.Filter = "NTDueDate = " & Format(Me.FindDate1, "\#mm\/dd\/yyyy\#")
Me.FilterOn = True
Else
Me.FilterOn = False
End If

I have adopted the above code first to find a date in a record set and then
filter the records based on the date found. I have an option group which
shows all records as the default and if a date is found and I choose option
2, I am expecting to get only those records with the due dates found.
Finding the date and the first matching record is fine however when I choose
option 2 an empty record is displayed. FindDate1 is a combo box and
FilteredRecords1 is an option group with 2 options show all records and show
only the records found. Am I missing something here? Any suggestions/
assistance would be greatly appreciated
 
You need to put the ## like
Me.Filter = "NTDueDate = #" & Format(Me.FindDate1, "yyyy/mm/dd") & "#"
 
Well add a msgbox like
If FilteredRecords1 = 2 Then
Me.Filter = "NTDueDate = " & Format(Me.FindDate1,
"\#mm\/dd\/yyyy\#")
MsgBox Me.Filter
Me.FilterOn = True
Else
Me.FilterOn = False
End If

to see if the filter is the right one. You may need to remove the
filter first or read the FindDate1 again.
 
Back
Top