Remove table property Caption

R

Ross

I have written some code that allows me to append a name to a caption
property on a field in a table.

'Grouping _1
<><><>/<><><>/<><><>/<><><>/<><><>/<><><>/<><><>/<><><>
myString = grp1_Name
Set db = CurrentDb
Set TDF = db.TableDefs!tblCompare
Set FLD = TDF.Fields("Grouping_1")
Set PRP = FLD.CreateProperty("Caption", dbText, myString)
FLD.Properties.Append PRP

This code works only when the caption for the Grouping_1 field is empty. I
cannot edit the caption if a caption already exists.
‘<><><>/<><><>/<><><>/<><><>/<><><>/<><><>/<><><>/<><><>/

How do I remove the caption from the field at a later time (when I close a
form)?

I have tried, null, empty, “â€, “ “ without success.

Thank you

Ross
 
A

Allen Browne

Grab the SetPropertyDAO() function from the bottom of this page:
http://allenbrowne.com/AppPrintMgtCode.html#SetPropertyDAO

It sets the property if it exists, or creates and sets it if it does not
exist.

You also need the HasProperty() function (the very last one on the page.)

Call it like this in place of your last 2 lines:
Call SetPropertyDAO(fld, "Caption", dbText, mystring)

Alternatively, if you want to know the outcome:
Dim strMsg As String
If Not SetPropertyDAO(fld, "Caption", dbText, mystring, strMsg) Then
If strMsg <> vbNullString Then
MsgBox strMsg, vbExclamation, "Oops"
End If
End If
 
R

Ross

Allen,

Thank you,

I don't think I could have figure this out by trial and error.

I will be able to do some fantastic things if this will work!

Thanks agian,

Ross
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top