By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,364 Members | 1,493 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,364 IT Pros & Developers. It's quick & easy.

Changing caption content in a Table or Form

P: n/a
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



Dec 4 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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


Dec 4 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.