RE: Field Caption





"DennisGuilbault" wrote:

> Does anyone know how to get and set the caption property of a field in a
> table, using vba?

Dennis,

I was also looking to find out whether or not it was possible to set the
caption of the field in a table using VBA. Using Tim's response, even though
I didn't appreciate him lecturing about how "there was no logical reason for
doing this", I was able to get it done.

Try this code...

Sub FieldX()

Dim dbs As Database
Dim fld As Field
Dim prpCaption As Property

Set dbs = CurrentDb
Set fld = dbs.TableDefs("your_table").Fields("field_name")
Set prpCaption = fld.CreateProperty("Caption", dbText, "your_text_here")

On Error Resume Next
fld.Properties.Append prpCaption
dbs.Close

End Sub

Hope this helps you out.

Dave
.



Relevant Pages

  • Re: Finding and Replacing a Certain Word from 100+ Documents
    ... I have never read a book on VBA. ... Word MVP web site http://word.mvps.org ... Dim FirstLoop As Boolean ...
    (microsoft.public.word.vba.general)
  • Re: SumProduct, Match in a UDF
    ... dim vData as variant ... I definitely need help w/ arrays & VBA, ... All these named ranges will always be available for formula, ... UDF parameter list. ...
    (microsoft.public.excel.programming)
  • Re: Request help with a custom date field - ? 4 Greg...
    ... Greg Maxey wrote: ... But, when I pasted the DateAddUp code in VBA, one line of code was ... Dim oFF As Word.FormFields ... calculations later in the form, such as with the code you've ...
    (microsoft.public.word.vba.beginners)
  • RE: To prompt us to copy from
    ... directly from VBA without having to shell a cmd line. ... Dim sDest As String ... 'Make sure the \ is between the folder and filename ...
    (microsoft.public.access.modulesdaovba)
  • RE: To prompt us to copy from
    ... directly from VBA without having to shell a cmd line. ... Dim sDest As String ... 'Make sure the \ is between the folder and filename ...
    (microsoft.public.access.modulesdaovba)

Loading