Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / SQL Server / ADP / August 2005

Tip: Looking for answers? Try searching our database.

Retrieve the Caption property of a field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Adam Goossens - 17 Aug 2005 01:54 GMT
Hi all,

Does anybody know how I can read the value of the Caption property of a
SQL Server field (as set by Access) at run time?

I need to export some data to Excel (I can't assume it'll always be one
kind of data - I want to be able to pass any SQL string and spit out an
Excel document) and I'm thinking of using the Caption property of the
various fields to store a "user friendly" name, aka "Vendor Name"
instead of "fldVendorName".

Or, if anybody has any alternate suggestions for what I wish to do, I'd
be glad to hear them!

Many thanks,
-Adam.
pjgalloway - 23 Aug 2005 16:30 GMT
I have not worked with captions on a SQL table but with Access tables the
only trick is that it will bomb if there is not a caption defined for the
field so you need some error handling to deal with that case to perhaps just
use the field name.  Note that if you are referencing both ADO and DAO as I
am, then you do need to use a DAO field variable and not an ADO field
variable.

   On Error GoTo HandleErrors
   Dim strCaption as string    
   Dim db As Database
   Dim tdf As TableDef
   Dim fld As DAO.Field
   Set db = CurrentDb()
   Set fld = tdf.Fields("yourfield")
   strCaption = ""
   On Error Resume Next
   strCaption = fld.Properties("Caption")
   On Error GoTo HandleErrors
   If strCaption = "" Then strCaption = fld.Properties("Name")
               

Signature

- Paula

> Hi all,
>
[quoted text clipped - 12 lines]
> Many thanks,
> -Adam.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.