Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Chapel Hill, North Carolina, USA
    Posts
    138
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Reading Inputmask and descriptions in VBA (2000/XP)

    I am writing a simple database documentor to pull out just a few key field properties from a database. (I teach a database design class and need a quick way to identify if students have added input masks, validation rules/text and default values to their tables). I've found everything by input masks and field descriptions under recordset.properties(1).name...is there an easy was to pull out the field description and identify if an input was defined for the field?

    Thanks!

    Larry

  2. #2
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reading Inputmask and descriptions in VBA (2000/XP)

    Larry,

    If you use DAO, you can use the TableDefs and Fields properties to get the info you need. Here is a quick sub that will loop through all the fields in a table (tblRead) and print to the immediate window, the field name, the Input Mask (if any) and the Description (if any):

    Dim db As DAO.Database
    Dim tdf As DAO.TableDef
    Dim fld As DAO.Field
    Dim prp As DAO.Property

    Set db = CurrentDb

    Set tdf = db.TableDefs("tblRead")

    On Error Resume Next

    For Each fld In tdf.Fields
    Debug.Print fld.Name
    Debug.Print fld.Properties("InputMask")
    Debug.Print fld.Properties("Description")
    Next

    Set fld = Nothing
    Set tdf = Nothing
    Set db = Nothing

    You need to use the On Error Resume Next, because if either of the description Property or the InputMask property of the field don't exists, it will cause an error.

    Some of the field properties don't exists until you actually assign a value to them.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  3. #3
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Chapel Hill, North Carolina, USA
    Posts
    138
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reading Inputmask and descriptions in VBA (2000/XP)

    Brian,

    Thanks - that's simpler than I thought - didn't know I could specify properties that weren't on the original list.

    Thanks again!

    Larry

Posting Permissions

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