FieldSize Property Example

This example uses the FieldSize property to list the number of bytes used by the Memo and Long Binary Field objects in two different tables.

Sub FieldSizeX()

   Dim dbsNorthwind As Database
   Dim rstCategories As Recordset
   Dim rstEmployees As Recordset

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
   Set rstCategories = _
      dbsNorthwind.OpenRecordset("Categories", _
      dbOpenDynaset)
   Set rstEmployees = _
      dbsNorthwind.OpenRecordset("Employees", _
      dbOpenDynaset)

   Debug.Print _
      "Field sizes from records in Categories table"

   With rstCategories
      Debug.Print "  CategoryName - " & _
         "Description (bytes) - Picture (bytes)"

   ' Enumerate the Categories Recordset and print the size 
   ' in bytes of the picture field for each record.
      Do While Not .EOF
         Debug.Print "    " & !CategoryName & " - " & _
            !Description.FieldSize & " - " & _
            !Picture.FieldSize
         .MoveNext
      Loop

      .Close
   End With

   Debug.Print "Field sizes from records in Employees table"

   With rstEmployees
      Debug.Print "  LastName - Notes (bytes) - " & _
         "Photo (bytes)"

   ' Enumerate the Employees Recordset and print the size 
   ' in bytes of the picture field for each record.
      Do While Not .EOF
         Debug.Print "    " & !LastName & " - " & _
            !Notes.FieldSize & " - " & !Photo.FieldSize
         .MoveNext
      Loop

      .Close
   End With

   dbsNorthwind.Close

End Sub