[AccessD] Odd property error

A.D.TEJPAL adtp at airtelbroadband.in
Mon Nov 26 00:43:53 CST 2007


Susan,

    On Error Resume Next is found to work smoothly at my end. Sample subroutine named P_ListQryFieldDescr() is given below. It outputs only those fields where description property is not blank.

    If you are interested in listing all fields and show description where available (otherwise N.A.), sample subroutine named P_ListQryFieldDescr_A() as given below, will do the needful.

Best wishes,
A.D.Tejpal
------------

'====================================
Sub P_ListQryFieldDescr(QryName As String)
    On Error Resume Next
    Dim qdf As QueryDef, fd As Field
    
    Set qdf = CurrentDb.QueryDefs(QryName)
    
    For Each fd In qdf.Fields
        Debug.Print fd.Name & " - (" & _
                    fd.Properties("Description") & ")"
    Next
    
    Set fd = Nothing
    Set qdf = Nothing
    On Error GoTo 0
End Sub
'------------------------------------------------------

Sub P_ListQryFieldDescr_A(QryName As String)
    On Error Resume Next
    Dim qdf As QueryDef, fd As Field
    Dim Txt As String
    
    Set qdf = CurrentDb.QueryDefs(QryName)
    
    For Each fd In qdf.Fields
        Err.Clear
        Txt = fd.Properties("Description")
        If Err.Number = 0 Then
            Debug.Print fd.Name & " - (" & _
                    fd.Properties("Description") & ")"
        Else
            Debug.Print fd.Name & " - (N.A.)"
        End If
    Next
    
    Set fd = Nothing
    Set qdf = Nothing
    On Error GoTo 0
End Sub
'====================================

  ----- Original Message ----- 
  From: Susan Harkins 
  To: AccessD at databaseadvisors.com 
  Sent: Monday, November 26, 2007 06:59
  Subject: [AccessD] Odd property error


  I'm using the following statement to retrieve the description properties for 
  query fields:

  SetFieldDescription = fld.Properties("Description")

  As long as there's a description, it works fine. An empty property returns 
  the error "property not found"

  I've tried a Resume Next error statement, but VBA acts like it isn't even 
  there and still returns the error.

  I've tried numerous ways to avoid or capture it, and nothing's worked.

  As far as I know, Description isn't user-defined and I think VBA's just 
  returning one of its many, famous erroneous error messages that aren't so 
  terribly helpful. However, you'd think Resume Next would ignore it, but it 
  doesn't seem to.

  Anyone seen anything like this before?

  I haven't tried a real error handling routine because I'd hoped to avoid 
  doing so if there was an easier solution.

  Susan H. 


More information about the AccessD mailing list