Results 1 to 2 of 2

Thread: How to get a field caption from an MDB

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Location
    Wellington NZ
    Posts
    153

    Talking

    Hi there i was wondring if it is possible to use some VB code to access the caption of a field in a MDB...

    It is possible to get the name of the field but i am not sure how to get the caption...

    Any ideas?

    Rohan

  2. #2
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    To access non-DAO properties of objects, you need to reference the object's Properties collection, and specify the property you want, such as Caption, Description, etc.
    To satisfy your question, here's an example that will iterate through a table and print its field names along with their Captions:

    Code:
        Dim dbs As Database
        Dim rst As Recordset
        Dim fld As Field
        
        Set dbs = OpenDatabase("C:\Whatever\MyData.mdb")
        Set rst = dbs.OpenRecordset("MyTable")
        Debug.Print "Field Name", "Caption"
        For Each fld In rst.Fields
            Debug.Print fld.Name, fld.Properties("Caption")
        Next
    "It's cold gin time again ..."

    Check out my website here.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width