p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   Access VBA (http://p2p.wrox.com/access-vba-80/)
-   -   Truncated field when copying (http://p2p.wrox.com/access-vba/50275-truncated-field-when-copying.html)

Tachyophan November 14th, 2006 08:54 AM

Truncated field when copying
I have a form based on a table containing 2 memo fields :
fld_base_text and fld_edit_text.
I have created a button that copies the text from field to field.
The command is the following :
fld_edit_text = fld_base_text
The problem is that if the field content is too long, the copied text is truncated.
Oddly enough, if I copy/paste with the mouse or the shortcut keys, then there is no problem.
Any solution or suggestion ?

mmcdonal November 14th, 2006 01:16 PM

I think your code is only taking the first 256 characters of the memo field. I think you may have to do this in a DAO recordset.

Why are you using two fields with the same data in the same table?


Tachyophan November 16th, 2006 04:13 AM

Do you have an idea of the coding here?
If I am using twice the same field, it is for the following reason :
fld_base_text is the original text that CANNOT be modified
fld_edit_text is a copy of the original version that can be completely modified (depending on the case)

mmcdonal November 16th, 2006 08:23 AM

Okay, here is the code that I used that transfer more than 256 characters from one memo field to another. This works, but I have to click it twice to get the text to show up in the form. I am not sure why that is.

I used a table called Table1, and TableID as an Autonumber PK, with Memo1 and Memo2 memo fields.


'---------Button On Click Event----------
Private Sub Command6_Click()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sSQL As String
Dim sID As Integer

sID = Me.TableID

sSQL = "SELECT * FROM Table1 WHERE TableID = " & sID

'Open Local Connection
Set cn = New ADODB.Connection
With cn
    .ConnectionString = CurrentProject.Connection
    .CursorLocation = adUseClient
End With

'Open Recordset
Set rs = New ADODB.Recordset
    rs.CursorType = adOpenDynamic
    rs.LockType = adLockOptimistic
    rs.Open sSQL, cn

'Move contents of one memo field to the other.
rs("Memo2") = rs("Memo1")

'Clean Up

'Try to get the Memo2 field on the form to show current state.

End Sub
'----------End Code------------


All times are GMT -4. The time now is 04:38 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
2013 John Wiley & Sons, Inc.