Getting the field caption property from code in Access97


Question

Since my field names for my tables and queries are not clear, I would like to get the field caption from the tables and queries through code so that I can put these on forms. Any ideas on how to do this?

Answer


Here is the function to solve the subject's task:

Function GetCaption(strTableName As String, strField As String) As Variant
     on error resume next
     GetCaption=dbengine(0)(0).TableDefs(strTableName).Fields(strField).Properties("caption")
End Function

HTH,
Shamil

 


Copyright 1999-2008 by Shamil Salakhetdinov. All rights reserved.