J
JamesJ
Hi. I'm using a label 'lblCount' to display the number of records
returned in a recordset. I want the label to display "No Records"
if no records are returned.I've tried checking for a null value in
the Primary Index field 'ProductID' and have tried checking to see
if the RecordCount is >0. nothing seems to work. When I use
the following code the label displays "No Records even when there
are records. If I remove the If...RecordCount>0 If statement
and unremark out the If IsNull... the correct number of records are
displayed in the label but when no records are returned the
label simply displays the last recordcount.
Private Sub Form_Current()
Dim RecClone As DAO.Recordset
Dim intCount As Integer
Set RecClone = Me.RecordsetClone()
'If IsNull(Me!ProductID) Then
If RecordsetClone.RecordCount > 0 Then
Me!lblCount.Caption = "No Records"
Else
RecClone.MoveLast
intCount = RecClone.RecordCount
RecClone.Bookmark = Me.Bookmark
lblCount.Caption = intCount & " Item(s)"
'End If
End If
RecClone.Close
Set RecClone = Nothing
End Sub
Any help will be appreciated,
James
returned in a recordset. I want the label to display "No Records"
if no records are returned.I've tried checking for a null value in
the Primary Index field 'ProductID' and have tried checking to see
if the RecordCount is >0. nothing seems to work. When I use
the following code the label displays "No Records even when there
are records. If I remove the If...RecordCount>0 If statement
and unremark out the If IsNull... the correct number of records are
displayed in the label but when no records are returned the
label simply displays the last recordcount.
Private Sub Form_Current()
Dim RecClone As DAO.Recordset
Dim intCount As Integer
Set RecClone = Me.RecordsetClone()
'If IsNull(Me!ProductID) Then
If RecordsetClone.RecordCount > 0 Then
Me!lblCount.Caption = "No Records"
Else
RecClone.MoveLast
intCount = RecClone.RecordCount
RecClone.Bookmark = Me.Bookmark
lblCount.Caption = intCount & " Item(s)"
'End If
End If
RecClone.Close
Set RecClone = Nothing
End Sub
Any help will be appreciated,
James