VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Quick Recordset Properties List

by Brian Battles WS1O (15 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

If you're ever wondering what's contained in a recordset you currently have open, here's a quick and dirty way to dump all the data you could want to the Immediate window, which you can view there, or copy and paste into a notepad document or other textfile for printing, etc.
I like to keep this somewhere I can quickly copy and paste it into any module or routine that uses a recordset in case I lose track of which field is which.
(I've only tried this with VB 6.0 and AO 2.6, but I imagine it would work with other versions.)
--Brian Battles WS1O
Middletown, CT USA

Assumes
Needs a currently open recordset
Code Returns
A list of fields and property info in the Immediate window
Side Effects
none known

Rate Quick Recordset Properties List

Private Sub ListRecordsetProperties()
  ' provides a list of all current recordset fields and their properties;
  ' use with any currently open ADO recordset (rs in this example)
  Dim I As Integer
  Dim J As Integer
  
  For I = 0 To rs.Fields.Count - 1
    Debug.Print vbCrLf & "Field " & I & " Name: '" & rs.Fields.Item(I).Name & "'" & vbTab & "Value: '" & rs.Fields(I).Value & "'" & vbCrLf & " Properties..."
    For J = 0 To rs.Fields(I).Properties.Count - 1
      Debug.Print "  Index(" & J & ") " & "Name: " & rs.Fields(I).Properties(J).Name & " = " & rs.Fields(I).Properties(J).Value & vbTab & vbTab & "Type: " & rs.Fields(I).Properties(J).Type & "," & vbTab & "Attributes: " & rs.Fields(I).Properties(J).Attributes
    Next J
  Next I
End Sub

Download this snippet    Add to My Saved Code

Quick Recordset Properties List Comments

No comments have been posted about Quick Recordset Properties List. Why not be the first to post a comment about Quick Recordset Properties List.

Post your comment

Subject:
Message:
0/1000 characters