?
Solved

Record Count on Search Results

Posted on 2006-10-26
2
Medium Priority
?
215 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month13 days, 6 hours left to enroll

777 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