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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem appending to Memo field

Status
Not open for further replies.

PantoKing

Technical User
Nov 28, 2001
169
GB
Hello,

I am currently getting a problem transfering some data using vba.

When populating a memo field from VB using DAO the string data I am appending is truncated to 255 characters.
However the string is more than 255 characters long, it shows okay in the immediate window but in the destination table is truncated.

I haven't got a clue what to do, can any of you help?

Any help would be appreciated!

Thanks in advance,

Steve.



Make things as simple as possible — but no simpler. [pc3]
 
I'm not exactly sure what you mean by "populating a memo field from VB", but it might be helpful to show your code.
Also doublecheck that the destination field is indeed a memo field and not a text field.

Cheers,
Bill
 
yep, the destination field is definitely a memo field.

The code is as follows

Dim strErrorInfo As String: strErrorInfo = ""
Dim rstErrors As DAO.Recordset

Set rstErrors = db.OpenRecordset("tbl_P&SImportValidationErrors", dbOpenDynaset)

Rest of code here…

With rstErrors
.AddNew
.Fields("MPR") = varMPRN
.Fields("StartRecDate") = varStartReadDate
.Fields("EndRecDate") = varEndReadDate

.Fields("ErrorDescription") = "Record " & lngRecordCount & ": " & strErrorInfo - This is the line causing the error

.Update
End With



The line highlighted above is where the problem lies. strErrinfo is often more the 255 characters but it is being truncated to 255 characters in the table.

thanks for any help!





Make things as simple as possible — but no simpler. [pc3]
 
Well, there isn't any fundamental reason why the memo field won;t accept more than 255 characters. And there is nothign in your code that raises a flag, although I don;t know how a value is being passed to strErrorInfo. So here are some shots in the dark to hopefully narrow down the origin of the problem.


Check and see what is actually geting passed to the table.
Code:
Debug.print Len(strErrorInfo) & ": " & strErrorInfo
.Fields("ErrorDescription") = "Record " & lngRecordCount & ": " & strErrorInfo

Then to make sure that part of the field's contents just aren't coming to view, try a query along the following lines:
Code:
SELECT Len([tbl_P&SImportValidationErrors].[ErrorDescription]) AS FieldLen
FROM tbl_P&SImportValidationErrors;

Cheers, Bill
 
How is strErrorInfo being set? We see it dimmed and then

Code:
strErrorInfo = ""

and then nothing until

Code:
.Fields("ErrorDescription") = "Record " & lngRecordCount & ": " & strErrorInfo

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top