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
|