Solved

Record Count on Search Results

Posted on 2006-10-26
2
212 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…

734 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