Results 1 to 2 of 2

Thread: [RESOLVED] Determine if Filter Returns nothing

  1. #1

    Thread Starter
    Fanatic Member Jumpercables's Avatar
    Join Date
    Jul 2005
    Location
    Colorado
    Posts
    592

    Resolved [RESOLVED] Determine if Filter Returns nothing

    How can I determine if the filter that I just created at run-time returns nothing. This is what I am trying however it seems to return the wrong recordcount and records. I am using VBA / Access 2002

    VB Code:
    1. SQL = "Name LIKE '* TODD *'"
    2. 'Determine if there are any records to show
    3.         Form_frmLocateSuboenaSubfrm.Filter = SQL
    4.         Form_frmLocateSuboenaSubfrm.FilterOn = True
    5.         Form_frmLocateSuboenaSubfrm.Requery
    6.        
    7.         Dim Qry As Recordset
    8.         Set Qry = CurrentDb.OpenRecordset( Form_frmLocateSuboenaSubfrm.Filter)
    9.         'Set Qry = CurrentDb.OpenRecordset( Form_frmLocateSuboenaSubfrm.RecordSource)
    10.        If Qry.RecordCount = 0 Then
    11.               MsgBox("No Match Found!")
    12.        Else
    13.               Form_frmLocateSuboenaSubfrm.FilterOn = false
    14.        End If

    However when I do this there should be 2 names with TODD, but the recordset shows 1 record, but the name is KIM.

    C# - .NET 1.1 / .NET 2.0

    "Take everything I say with a grain of salt, sometimes I'm right, sometimes I'm wrong but in the end we've both learned something."
    _____________________
    Regular Expressions Library
    Connection String
    API Functions
    Database FAQ & Tutorial

  2. #2

    Thread Starter
    Fanatic Member Jumpercables's Avatar
    Join Date
    Jul 2005
    Location
    Colorado
    Posts
    592

    Re: Determine if Filter Returns nothing

    I figured it out, but incase anyone else wants to know I did it like the following..
    VB Code:
    1. Dim Rst As Recordset
    2.         Set Rst = Form_frmLocateSuboenaSubfrm.RecordsetClone
    3.         If Rst.RecordCount = 0 Then
    4.             'No Records Found
    5.             Call InfoBox("There were no matchs found!")
    6.             cmdClearSearch_Click
    7.         Else
    8.             Form_frmLocateSuboenaSubfrm.Requery
    9.         End If

    C# - .NET 1.1 / .NET 2.0

    "Take everything I say with a grain of salt, sometimes I'm right, sometimes I'm wrong but in the end we've both learned something."
    _____________________
    Regular Expressions Library
    Connection String
    API Functions
    Database FAQ & Tutorial

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width