Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleRead properties from a DAO recordset
DescriptionThis example shows how to read properties from a DAO recordset in Visual Basic 6.
KeywordsDAO, recordset, property
CategoriesDatabase
 
The program creates a DAO recordset and then loops through its Properties collection.
 
Private Sub Form_Load()
Dim txt As String
Dim db_path As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim i As Integer
Dim prop_name As String
Dim prop_value As String

    ' Open the database.
    db_path = App.Path
    If Right$(db_path, 1) <> "\" Then db_path = db_path & _
        "\"
    db_path = db_path & "Students.mdb"
    Set db = DAO.OpenDatabase(db_path)

    ' Open the recordset.
    Set rs = db.OpenRecordset("SELECT * FROM Students")

    ' Display the properties.
    For i = 0 To rs.Properties.Count - 1
        On Error Resume Next
        prop_value = rs.Properties(i).Value
        If Err.Number <> 0 Then prop_value = "<ERROR: " & _
            Err.Description & ">"
        On Error GoTo 0

        txt = txt & i & ") " & rs.Properties(i).Name & _
            " = " & prop_value & vbCrLf
    Next i
    txtResults.Text = Replace(txt, Chr$(0), " ")

    rs.Close
    db.Close
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated