VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This Code Verifies if a recordset is empty or not ,and you can pass a collection for and it will fi

by Khalid Sweeseh (2 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 28th March 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This Code Verifies if a recordset is empty or not ,and you can pass a collection for and it will fill it for you with the Values in the

Rate This Code Verifies if a recordset is empty or not ,and you can pass a collection for and it will fi



   On Error GoTo ErrH
   Dim TmpField As Field
   Dim TmpColl As Collection
   
        If ReturnColl Then
            If Not (rColl Is Nothing) Then Set rColl = ReturnEmptyCollection
        End If
        
        If (MyRS.EOF And MyRS.BOF) Then
             VerifyRS = False
             Exit Function
        End If
    
        If ReturnColl = False Then
            VerifyRS = True
            Exit Function
        End If
    
 
    Set TmpColl = New Collection
    While Not MyRS.EOF
        For Each TmpField In MyRS.Fields
            TmpColl.Add MyRS.Fields(CStr(TmpField.Name)) & " "
        Next
        MyRS.MoveNext
    Wend
    MyRS.MoveFirst
    VerifyRS = (CheckForNulls(TmpColl) = True)
        If ReturnColl = True Then
            If Not (rColl Is Nothing) Then
                Set rColl = TmpColl
            Else
                VerifyRS = False
            End If
        End If
    Exit Function
ErrH:
    VerifyRS = False
End Function



Public Function CheckForNulls(sStrings As Collection) As Boolean
On Error GoTo ErrH
Dim sElement As Variant
Dim NoNullCollection As Collection
Set NoNullCollection = New Collection
        For Each sElement In sStrings
            If Trim(sElement) <> "" Then
                sElement = Trim(sElement)
                NoNullCollection.Add sElement
            End If
        Next
    CheckForNulls = True
    Set sStrings = NoNullCollection
    Exit Function
ErrH:
    CheckForNulls = False
End Function

Public Function ReturnEmptyCollection() As Collection
    Set ReturnEmptyCollection = New Collection
End Function



Download this snippet    Add to My Saved Code

This Code Verifies if a recordset is empty or not ,and you can pass a collection for and it will fi Comments

No comments have been posted about This Code Verifies if a recordset is empty or not ,and you can pass a collection for and it will fi. Why not be the first to post a comment about This Code Verifies if a recordset is empty or not ,and you can pass a collection for and it will fi.

Post your comment

Subject:
Message:
0/1000 characters