To add/change the caption property of a field in a table you do something
like this.
Sub AddFieldCaption(TabName As String, FldName As String, NewCaption As
String)
Dim loDB As DAO.Database
Dim loTab As DAO.TableDef
Dim loFld As DAO.Field
Dim loProp As DAO.Property
On Error GoTo AddFieldCaption_Error
Set loDB = CurrentDb
Set loTab = loDB.TableDefs(TabName)
Set loFld = loTab.Fields(FldName)
Set loProp = loFld.Properties("Caption")
loProp.Value = NewCaption
AddFieldCaption_Exit:
On Error Resume Next
Set loProp = Nothing
Set loFld = Nothing
Set loTab = Nothing
Set loDB = Nothing
On Error GoTo 0
Exit Sub
AddFieldCaption_Error:
Stop
Select Case Err
Case 3270
Set loProp = loFld.CreateProperty("Caption", dbText, NewCaption)
loFld.Properties.Append loProp
Case Else
' other error handling code here
End Select
Resume AddFieldCaption_Exit
End Sub
--
Terry Kreft
"S. van Beek" <S.******@HCCnet.nl> wrote in message
news:43*********************@textreader.nntp.hccne t.nl...
Dear reader,
I can change the caption content of a field in a Form with the following
VBA
code:
Rst!<FieldName>.Caption = "<NewCaptionContent>"
But if I do the same in a Table the following error message pops up:
"Method or data member not found"
Is there another VBA code available to do this in a Table or is it not
possible to change the Caption content with VBA in a Table?
Thanks for any help.
Kind regards,
Simon van Beek