Navigation:  Articles > Sep-1997 >

Tip: Easily Display Properties

Previous pageReturn to chapter overviewNext page

Stephen Sarre          
 
When debugging code, I often want to be able to check out all the properties of current objects. When in step mode, I can enter something like this:
 

? rec.fields(inti).Name

? rec.fields(inti).Value

? rec.fields(inti).Type

 
 
I do this so often that I find it more convenient to use a utility function like the one shown below. (The Access 2.0 version is shown. The Access 95 and 97 versions could use the For Each prp In pfld.Properties construct.)
 

Function SISDebugPrintFieldProperties (pfld As Field) As Integer

 

Dim intProperty As Integer

Dim intPropertyCount As Integer

Dim prp As Property

Dim varValue As Variant

 

On Error GoTo SISDebugPrintFieldProperties_Err

 

   intPropertyCount = pfld.properties.count

   For intProperty = 0 To intPropertyCount - 1

       Set prp = pfld.properties(intProperty)

       On Error Resume Next

       varValue = prp.value

       Select Case Err

         Case 0

         Case 3219

           varValue = "Invalid operation"

         Case Else

           MsgBox "Unexpected case err" & Err & _

             Error & _

             " in SISDebugPrintFieldProperties"

       End Select

       On Error GoTo SISDebugFieldProperties_Err

       Debug.Print prp.name, varValue

   Next intProperty

 

   SISDebugPrintFieldProperties = True

 

SISDebugFieldProperties_Done:

   Exit Function

 

SISDebugPrintFieldProperties_Err:

   MsgBox Error & CStr(Err)

   Resume SISDebugPrintFieldProperties_Done

End Function

 
 
You can just enter the following code to display all the properties for a field:
 

? SISDebugPrintFieldProperties(rec.fields(inti))