Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 187
  • Last Modified:

Using Memo field

I am making a program that updates a memo field using an adodb recordset.  I need to update the field by adding text to the end.  But when I open the recordset for some reason it overwrites the existing text.  I beleive it has to do with the lockcode.  when I do not set a lockcode I am able to view the memo in a textfield, but I am not able to update the field.  When I set it to any other lockcode I cannot view it, but I can update it but it overwrites the current text.  Here is my code...

    'Open Comments Recordset
    sqlMemo = "SELECT MemoField FROM Comments"
    Set rsMemo = New ADODB.Recordset
    rsMemo.LockType = adLockOptimistic
    Call rsMemo.Open(sqlMemo, connAccounts)

    rsMemo.Fields("MemoField").Value = rsMemo.Fields("MemoFeild").Value & "Updated Text"
    rsMemo.UpdateBatch

This let's me update but overwrites existing data.  HELP!
0
completefear
Asked:
completefear
1 Solution
 
vinnyd79Commented:
is this line just a typo where MemoField is spelled wrong?

   rsMemo.Fields("MemoField").Value = rsMemo.Fields("MemoFeild").Value & "Updated Text"
   
0
 
completefearAuthor Commented:
it is a typo.  It is correct in my code.  Sorry about that.  I do not get an error becuase of the field name.
0
 
WHalphenCommented:
The UpdateBatch method requires a LockType of adLockBatchOptimistic.  Try this for your locktype.  
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
WHalphenCommented:
If the LockType of adLockBatchOptimistic does not work try using transactions and the Update method:

connAccounts.BeginTrans
rsMemo.Fields("MemoField").Value = rsMemo.Fields("MemoField").Value & "Updated Text"
rsMemo.Update
connAccounts.CommitTrans

This will provide some shielding between your memo field read and the memo field write, ensuring that the read finishes before the write begins.
0
 
gvpathi_devCommented:
The problems are not with Lock Type.  It is with the Memofield type.  Please use getChunk and putChunk of Field object to put data reliably.  If the data size is more than ~>65000 the string will not be concatenated and put back.  

Try with getChunk and putChunk of Field object.  if you have any problem in usage pl. write.

Hope this will solve the problem.

GVPathi
0
 
cerebralpcCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept  WHalphen  comment as answer.

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
cerebralPC
EE Cleanup Volunteer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now