Solved

Record Count on Search Results

Posted on 2006-10-26
2
214 Views
Last Modified: 2010-04-23
Hi

I have some code that searches on various fields on an Access DB. Everything works fine, however I would like to populate a label with the number of records found.

This is my code for the search:

Private Sub txtSearch_TextChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSearch.TextChanged

        Dim dvFilter As DataView = Nothing

        If TypeOf dgAssets.DataSource Is DataView Then
            dvFilter = CType(dgAssets.DataSource, DataView)
        ElseIf TypeOf dgAssets.DataSource Is DataTable Then
            dvFilter = CType(dgAssets.DataSource, DataTable).DefaultView
        End If

        If txtSearch.TextLength > 0 And RBEFCAssetTAG.Checked = True Then
            dvFilter.RowFilter = "EFCRef LIKE '" & txtSearch.Text & "*'"
        ElseIf txtSearch.TextLength > 0 And RBUser.Checked = True Then
            dvFilter.RowFilter = "User LIKE '" & txtSearch.Text & "*'"

        Else
            dvFilter.RowFilter = ""
        End If

        dgAssets.DataSource = dvFilter

    End Sub

Thanks
0
Comment
Question by:weight01
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 17

Accepted Solution

by:
ZeonFlash earned 500 total points
ID: 17814740
dvFilter.Count should contain the number of records in the dataview after the filters have been applied.
0
 
LVL 1

Author Comment

by:weight01
ID: 17814854
Thanks ZeonFlash, your help is appreciated, that worked fine.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

687 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question