Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 22nd, 2008, 11:49 AM
Authorized User
 
Join Date: Nov 2007
Location: Nederland, , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default record count help

Greetings,
I've got to do a count of all the records in a search.
Right now I've used an array to get the results but how can I also get a count of the records found. Example: if I search for the records that contain the REV letter "A" and I get a return showing 24 records, I want to have a msgbox the shows the number of records found is 24.
Here is my search code:
Private Sub TogFilter_Click()
    Dim strFilt(0 To 10) As String
    Dim aryIdx As Integer
    Dim FiltStr As String

    If TogFilter.Value = -1 Then
        If cboDwgNo.Value <> "" Then strFilt(0) = "[DwgNo] = '" & cboDwgNo.Value & "'"
        If cboLineNo.Value <> "" Then strFilt(1) = "[LineNo] = '" & cboLineNo.Value & "'"
        If cboDwgType.Value <> "" Then strFilt(2) = "[DwgType] = '" & cboDwgType.Value & "'"
        If cboPIDNo.Value <> "" Then strFilt(3) = "[PIDNo] = '" & cboPIDNo.Value & "'"
        If cboPipeSpec.Value <> "" Then strFilt(4) = "[PipeSpec] = '" & cboPipeSpec.Value & "'"
        If cboProjNo.Value <> "" Then strFilt(5) = "[ProjNo] = '" & cboProjNo.Value & "'"
        If cboRev.Value <> "" Then strFilt(6) = "[Rev] = '" & cboRev.Value & "'"
        If cboModule.Value <> "" Then strFilt(7) = "[Module] = '" & cboModule.Value & "'"
        If cboArea.Value <> "" Then strFilt(9) = "[Area] = '" & cboArea.Value & "'"
        If cboStress.Value <> "" Then strFilt(9) = "[StressRel] = '" & cboStress.Value & "'"
        If cboTracing.Value <> "" Then strFilt(10) = "[tracing] = '" & cboTracing.Value & "'"

        For aryIdx = LBound(strFilt) To UBound(strFilt)
            If strFilt(aryIdx) <> "" Then
                If FiltStr <> "" Then
                    FiltStr = FiltStr & " and " & strFilt(aryIdx)
                Else
                    FiltStr = strFilt(aryIdx)
                End If
            End If
        Next aryIdx
    End If

    If FiltStr = "" Then FiltStr = "[DwgNo] <> ''"
    FiltStr = "(" & FiltStr & ")"
    Me.Filter = FiltStr
    DoCmd.ApplyFilter , FiltStr
    Me.Refresh
End Sub

Thanks

 
Old January 22nd, 2008, 12:46 PM
Authorized User
 
Join Date: Nov 2007
Location: Nederland, , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have an Idea, I have 2 buttons for select and deselect all after I've filtered for the records. They use ADO or DAO recordset. I could use the recordcount method inside those options to return the number.

 
Old January 22nd, 2008, 02:49 PM
Authorized User
 
Join Date: Nov 2007
Location: Nederland, , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Nevermind on the idea, Because the count would only work when the select buttons is clicked. I need it to work when filtered.





Similar Threads
Thread Thread Starter Forum Replies Last Post
count no of record sanjeev jha ADO.NET 1 November 5th, 2007 12:28 PM
Record count deb1980 ASP.NET 2.0 Basics 6 April 10th, 2007 12:42 PM
Count Record prasanta2expert Access 3 November 28th, 2006 10:42 AM
How to count a record when it is not there Mitch Access 1 October 3rd, 2003 03:49 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.