Link to home
Start Free TrialLog in
Avatar of Sandra Smith
Sandra SmithFlag for United States of America

asked on

Show number of records on form-but only shows visible records count

I have the attched code that changes the records displayed bsed on project status.  However, the text contol that should display teh total records only shows the number of records visible, not the total number that are returns.  So, if the user sees only seven and then scrolls down, they can see all 24, but only 7 is displayed in the text control as the total count!  What is weired is sometimes when i step through the code, it does display teh correct number so I do not know why it only displays the count of visible records, not all records.

Sandra
Private Sub SelectProjects()
'Changes what projects are displayed based on user name and which category of projects are selected
'in the frame option box
'Resets recordsource for form based on user that has been selected
On Error GoTo ErrorHandler
Dim strSelect As String
Dim strStatus As String

Select Case Me.fraProjects
    Case 1
        strStatus = " AND ProjectStatus <> 'Closed' "
    Case 2
        strStatus = " AND ProjectStatus = 'Closed' "
    Case 3
        strStatus = ""
End Select
 
strSelect = "SELECT ProjectID, ProjectTitle, ProjectAssignedTo, ProjectStatus, StartDate, DueDate, ProjectDescription, Action " & _
   "FROM tblProjects WHERE ProjectAssignedTo = '" & Me.cboUserId.Column(0) & "' " & strStatus
Debug.Print strSelect

Me.RecordSource = strSelect
Me.Requery
Me.txtCount = Me.Recordset.RecordCount

Exit_ErrorHandler:
    Exit Sub
ErrorHandler:
    MsgBox "Error Number: " & Err.Number & vbCrLf & _
           "Error Description: " & Error.Description & vbCrLf & _
           "Procedure: SelectProjects() ", vbOKOnly
    Resume Exit_ErrorHandler
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sandra Smith

ASKER

That seemed to work.

Sandra