Allen Browne Function SetFieldDescription passing field description

  • Thread starter henryonyeagbako
  • Start date
H

henryonyeagbako

Im trying at present to use the SetfieldDescription Function that i
found on Allen Browne's website. I call the function in the following
way

Call SetFieldDescription(tdf, fld, xlWs.Cells(r, c).Offset(0,
3).Value)

where the description is read from an excel cell value. This passed
all the values correctly apart from the excel cell value that was not
recognised at all. So i decided to write the value of the cell to a
string so DescripText=xlWs.Cells(r, c).Offset(0, 3).Value 'the
description in excel cell is "Uniquely identifies the branch ID". I
then changed the call procedure to the following:

'Call SetFieldDescription(tdf, fld,DescripText)

The function yet again did not seem to pick up the passed description
text. Please does anyone have examples of passing values to the
function to enable it to set the description correctly.
 
A

Allen Browne

Presumably we are talking about the code in this link:
http://allenbrowne.com/func-DAO.html#SetFieldDescription

Is this a field in an Access table?
Or is it an attached table?

To trace what's going on, add the line:
Stop
just above the first line, i.e. abvove the If (fld.Attributes ...
When you run the code it will stop on this line.
Then press F8 repeatedly to trace what the code is doing.
 
H

henryonyeagbako

Presumably we are talking about the code in this link:
http://allenbrowne.com/func-DAO.html#SetFieldDescription

Is this a field in an Access table?
Or is it an attached table?

To trace what's going on, add the line:
Stop
just above the first line, i.e. abvove the If (fld.Attributes ...
When you run the code it will stop on this line.
Then press F8 repeatedly to trace what the code is doing.

The description field is basically the decsription column that you see
when you open the table in the design view and enter the field name,
data type and description. Im trying to utilise your function to write
to the description column anentry that is pulled from an excel file a
sample of the code is as shown below

Case "Text" 'Text Field
Set fld = .CreateField(xlWs.Cells(r, c).Value, dbText,
xlWs.Cells(r, c).Offset(0, 2).Value)

The above code works fine in creating the field

DescripText = xlWs.Cells(r, c).Offset(0, 3).Value
Call SetFieldDescription(tdf, fld,DescripText )
.Fields.Append fld

The problem only occurs when the function is called> When the focus
moves to the function, I type the following in the immediate window

?fld.name 'this gives me the correct name of the field passed as a
parameter to the function
?tdf.name 'this gives me the correct name of the table passed as a
parameter to the function

However the strDescrip remains a blank ""
 
A

Allen Browne

So strDescrip is a zero-length string?
Therefore the value you anticipated is not being passed into the function?

The code works with a local Access table.
Trying to set the Description property of a field in an attached table (an
attached XLS) may not work.
 
H

henryonyeagbako

So strDescrip is a zero-length string?
Therefore the value you anticipated is not being passed into thefunction?

The code works with a local Access table.
Trying to set the Description property of a field in an attached table (an
attached XLS) may not work.

--AllenBrowne- Microsoft MVP. Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.













- Show quoted text -

i have managed to get it to accept the description string as a
parameter by setting a variable to the cell value the problem now is
it steps through the code when it gets to the has property function it
flags this as false and then when it it gets to the followin section
of the set property function

If HasProperty(obj, strPropertyName) Then
obj.Properties(strPropertyName) = varValue
Else
obj.Properties.Append obj.CreateProperty(strPropertyName,
intType, varValue)
End If
SetPropertyDAO = True

ExitHandler:
Exit Function

ErrHandler:
strErrMsg = strErrMsg & obj.name & "." & strPropertyName & " not
set to " & varValue & _
". Error " & Err.Number & " - " & Err.Description & vbCrLf
Resume ExitHandler
End Function

because has proiperty is false it goes to the esle statement to create
a new property. But instead of creating a property it jumps to the
errhandler and gives an err.number of 3219 what does this mean.
 
A

Allen Browne

Error 3219 means "invalid operation."

Perhaps you are trying to do this on an attached table, which is not a valid
operation.
 
H

henryonyeagbako

Error 3219 means "invalid operation."

Perhaps you are trying to do this on an attached table, which is not a valid
operation.

I found out that the error related to the fact the tables i was
creating had not yet been appended to the tabledefs collection. So the
procedure now creates the tables and then calls your setpropertyDAO
and reads the description field from the excel spreadsheet. Thanks for
your much appreciated help
 

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