Results 1 to 3 of 3

Thread: [RESOLVED] Detecting missing RS fields

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    Up State NY
    Posts
    525

    Resolved [RESOLVED] Detecting missing RS fields

    Hope you guys have had coffee
    I have a control that you pass a recordset to to fill. Other designers using this control may miss the creation of one of the fields or a malformed RS arrives at the control.
    How can I detect the number of fields or their field names that is being passed with out a terminal error?

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Detecting missing RS fields

    This should give you some ideas. The code does assume that the current record is the first record.

    VB Code:
    1. Dim lngTotalFields as Long
    2. Dim oFields as ADODB.Fields
    3.  
    4. If Not rs Is Nothing Then
    5.    If rs.State = adStateOpen Then
    6.  
    7.       lngTotalFields = rs.Fields.Count
    8.  
    9.       For Each oField in Fields
    10.           'Do something            
    11.       Next
    12.  
    13.       If Not (rs.EOF And rs.BOF) Then
    14.          Do Until rs.EOF
    15.               'Do Something
    16.               rs.MoveNext
    17.          Loop
    18.       End If
    19. End If

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    Up State NY
    Posts
    525

    Re: Detecting missing RS fields

    LOL. I JUST finished writing a piece of code that does just that.
    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width