Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New Field Padding Problem in Access

Status
Not open for further replies.

mikemcginty

Programmer
Jul 11, 2002
184
0
0
AU
When I create a new text field (say size 20) in my Access database using ADO, the whole field is padded with spaces whenever I write data. The same does not happen if I create the new field directly using Access.

eg if I write "TEST" the "TEST " is returned

I also used Access to delete the additional spaces, but they automatically regenerate.

Any ideas

Mike

When you call out for help in the darkness, and you hear a voice in return, you're probably just talking to yourself again!
 
The app retrieves data through an ADO connection

The field is being padding by Access but only for fields I have created using ADO. When I manually create the field thru Access it is ok. All parameters of the ADO field seem the same as the manually created field.

Mike

When you call out for help in the darkness, and you hear a voice in return, you're probably just talking to yourself again!
 
Type TableField

Name As String ' name of the field
Type As Integer ' type of the field
DefinedSize As String
DefaultValue As Integer
End Type

Private sub AddFieldToTable()

Dim tFieldParameters As TableField

tFieldParameters.Name = "NewField"
tFieldParameters.Type = adWChar
tFieldParameters.DefinedSize = "100"

iDummy = iADOXAddTableField(tblMyTableName, tFieldParameters)

end sub

Private Function iADOXAddTableField(sTableName As String, tField As TableField) As Integer
' add a new field to an existing database table
' if the field already exists then the function exits

Dim cat As New ADOX.Catalog
Dim col As New ADOX.Column

On Error GoTo ExitError

' anticipate failure
' failure will occur if the field already exists
iADOXAddTableField = -1

' open the catalog
ADODBCheckConnection
cat.ActiveConnection = dbQADMObject

With col

.Name = tField.Name
.Type = tField.Type

If tField.DefinedSize <> "" Then _
.DefinedSize = tField.DefinedSize

End With

cat.Tables(sTableName).Columns.Append col

' return success
iADOXAddTableField = 1

ExitError:

Set cat = Nothing
Set col = Nothing

End Function

When you call out for help in the darkness, and you hear a voice in return, you're probably just talking to yourself again!
 
Thanks Peter

I will try that

Mike

When you call out for help in the darkness, and you hear a voice in return, you're probably just talking to yourself again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top