?
Solved

Using Memo field

Posted on 2003-03-05
6
Medium Priority
?
184 Views
Last Modified: 2013-12-25
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
Comment
Question by:completefear
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 28

Expert Comment

by:vinnyd79
ID: 8076287
is this line just a typo where MemoField is spelled wrong?

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

Author Comment

by:completefear
ID: 8076512
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
 

Expert Comment

by:WHalphen
ID: 8076883
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!

 

Accepted Solution

by:
WHalphen earned 150 total points
ID: 8076912
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
 
LVL 2

Expert Comment

by:gvpathi_dev
ID: 8078030
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
 
LVL 2

Expert Comment

by:cerebralpc
ID: 9026006
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question