473,388 Members | 1,207 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Editing Caption Property

I'm using the following code to try to change a caption property for a field
in a table.
Dim dbs As Database, fld As Field, fFormat As Property
Set dbs = OpenDatabase(CurrentDataFile)
Set fld = dbs.TableDefs(tblName).Fields(fldName)
Set fFormat = fld.CreateProperty("Caption", dbText, strCaption)
fld.Properties.Append fFormat

Each time it's generating error 3367 - "Cannot Append. An object with that
name already exists".
It doesn't matter what strCaption I enter, the same message appears.
I'm using Access 2002.
Any ideas welcome.

--
Bob Darlington
Brisbane
Oct 26 '07 #1
4 2708
"Bob Darlington" <bo*@dpcmanAX.com.auwrote in message
news:47***********************@news.optusnet.com.a u...
I'm using the following code to try to change a caption property for a
field in a table.
Dim dbs As Database, fld As Field, fFormat As Property
Set dbs = OpenDatabase(CurrentDataFile)
Set fld = dbs.TableDefs(tblName).Fields(fldName)
Set fFormat = fld.CreateProperty("Caption", dbText, strCaption)
fld.Properties.Append fFormat

Each time it's generating error 3367 - "Cannot Append. An object with that
name already exists".
It doesn't matter what strCaption I enter, the same message appears.
I'm using Access 2002.
Any ideas welcome.

--
Bob Darlington
Brisbane
This function first tries to set an already existing property, and if an
error 3270 (property not found) occurs, it appends the new property to the
collection. Paste it into a standard module:

''' BEGIN CODE '''
Sub SetObjProperty(pObject As Object, pProperty As String, pType As Integer,
pValue As Variant)
Const PROPERTY_NOT_FOUND As Long = 3270
Dim prp As Property
'
On Error GoTo SetObjProperty_Err
'
pObject.Properties(pProperty) = pValue
pObject.Properties.Refresh

SetObjProperty_Exit:
Set prp = Nothing
Exit Sub

SetObjProperty_Err:
If Err.Number = PROPERTY_NOT_FOUND Then
With pObject
Set prp = .CreateProperty(pProperty, pType, pValue)
.Properties.Append prp
.Properties.Refresh
End With
Resume SetObjProperty_Exit
Else
MsgBox Err.Number & ": " & Err.Description, vbCritical,
"SetObjProperty"
Resume SetObjProperty_Exit
End If

End Sub
''' END CODE '''

Use it like this:

SetObjProperty fld, "Caption", dbText, strCaption

Oct 26 '07 #2
"Bob Darlington" <bo*@dpcmanAX.com.auwrote in message
news:47***********************@news.optusnet.com.a u...
I'm using the following code to try to change a caption property for a
field in a table.
Dim dbs As Database, fld As Field, fFormat As Property
Set dbs = OpenDatabase(CurrentDataFile)
Set fld = dbs.TableDefs(tblName).Fields(fldName)
Set fFormat = fld.CreateProperty("Caption", dbText, strCaption)
fld.Properties.Append fFormat

Each time it's generating error 3367 - "Cannot Append. An object with that
name already exists".
It doesn't matter what strCaption I enter, the same message appears.
I'm using Access 2002.
Any ideas welcome.
Hi Bob.

Just a shot in the dark but wouldn't the property you're trying to create
already exist? Shouldn't you be trying to set its value rather than create
it?

Keith.
www.keithwilby.com

Oct 26 '07 #3
Thanks Stuart,
Sorry about the delay getting back to you.

--
Bob Darlington
Brisbane
"Stuart McCall" <sm*****@myunrealbox.comwrote in message
news:ff******************@news.demon.co.uk...
"Bob Darlington" <bo*@dpcmanAX.com.auwrote in message
news:47***********************@news.optusnet.com.a u...
>I'm using the following code to try to change a caption property for a
field in a table.
Dim dbs As Database, fld As Field, fFormat As Property
Set dbs = OpenDatabase(CurrentDataFile)
Set fld = dbs.TableDefs(tblName).Fields(fldName)
Set fFormat = fld.CreateProperty("Caption", dbText, strCaption)
fld.Properties.Append fFormat

Each time it's generating error 3367 - "Cannot Append. An object with
that name already exists".
It doesn't matter what strCaption I enter, the same message appears.
I'm using Access 2002.
Any ideas welcome.

--
Bob Darlington
Brisbane

This function first tries to set an already existing property, and if an
error 3270 (property not found) occurs, it appends the new property to the
collection. Paste it into a standard module:

''' BEGIN CODE '''
Sub SetObjProperty(pObject As Object, pProperty As String, pType As
Integer, pValue As Variant)
Const PROPERTY_NOT_FOUND As Long = 3270
Dim prp As Property
'
On Error GoTo SetObjProperty_Err
'
pObject.Properties(pProperty) = pValue
pObject.Properties.Refresh

SetObjProperty_Exit:
Set prp = Nothing
Exit Sub

SetObjProperty_Err:
If Err.Number = PROPERTY_NOT_FOUND Then
With pObject
Set prp = .CreateProperty(pProperty, pType, pValue)
.Properties.Append prp
.Properties.Refresh
End With
Resume SetObjProperty_Exit
Else
MsgBox Err.Number & ": " & Err.Description, vbCritical,
"SetObjProperty"
Resume SetObjProperty_Exit
End If

End Sub
''' END CODE '''

Use it like this:

SetObjProperty fld, "Caption", dbText, strCaption

Oct 30 '07 #4
Thanks Keith,
That was it (see Stuart's reply).
Sorry about the delay getting back to you.

--
Bob Darlington
Brisbane
"Keith Wilby" <he**@there.comwrote in message
news:47**********@glkas0286.greenlnk.net...
"Bob Darlington" <bo*@dpcmanAX.com.auwrote in message
news:47***********************@news.optusnet.com.a u...
>I'm using the following code to try to change a caption property for a
field in a table.
Dim dbs As Database, fld As Field, fFormat As Property
Set dbs = OpenDatabase(CurrentDataFile)
Set fld = dbs.TableDefs(tblName).Fields(fldName)
Set fFormat = fld.CreateProperty("Caption", dbText, strCaption)
fld.Properties.Append fFormat

Each time it's generating error 3367 - "Cannot Append. An object with
that name already exists".
It doesn't matter what strCaption I enter, the same message appears.
I'm using Access 2002.
Any ideas welcome.

Hi Bob.

Just a shot in the dark but wouldn't the property you're trying to create
already exist? Shouldn't you be trying to set its value rather than
create it?

Keith.
www.keithwilby.com

Oct 30 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Pavan Arise | last post by:
Hi all.. This may seem simple..but I am stuck here! I have a frame in which I have a label. I was trying to change the caption of that label via code (I mean at runtime & not design time). But...
2
by: F. GEIGER | last post by:
Hi all, I use PMW 1.2 on Python 2.3.0 on Win2k. I've created a dialog that looks like so: +----------------------+ Name | | +----------------------+...
9
by: Randall Sell | last post by:
Can anyone confirm if I am being an idiot, or is this a bug in the CSS implementation of Netscape 7.x/Mozilla 1.4 ... give the following single HTML: <html> <head> <style type="text/css">...
5
by: MLH | last post by:
This is one for you gurus. Someone has undoubtedly already done this. How difficult would it be to recurse all command buttons and textbox controls on all forms, appending an incrementing number to...
5
by: tsnyder | last post by:
I need to have an option button that allows editing to a field only when it is checked.
2
by: el_espasmo | last post by:
Yes... I know the question might be stupid but... I still want to try because I haven't been able to solve this. I have been trying to change some stuff in MySpace, but not in my profile, in...
6
by: Bob Darlington | last post by:
I want to use the caption property for fields in a recordset as a condition in a loop. That is, I only want to consider those fields which have captions: For each fld in RecordsetName.Fields If...
1
by: Simon | last post by:
Dear reader, I am familiar with the possibility to change the Caption of a field in a form. But is there also a possibility to change the Caption of a field in the table structure it self.
11
by: Chris Beall | last post by:
See http://pages.prodigy.net/chris_beall/Demo/photo%20block%20experiments.html I've ended up with what seems like a rather complex structure for what I thought would be a somewhat simple...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.