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

recordset displaying only the first 255 characters

Status
Not open for further replies.

davikokar

Technical User
May 13, 2004
523
IT
Hallo,

I have a table with two fields, one Memo and one date. In the meno field I store text longer then 255.

I make a query on this table in order to combine the two fields, in sql this would be something like
Code:
"SELECT [description] & [when] AS Expr1 FROM tblTest;"

The query works fine. Displays the result as expected: the two fields are concatenated.

Now if I open a recordset of this query and for example I try to write the data I will get only the first 255 characters and the rest of the text is messed up with unreadable characters.

This is the code I use to write to word
Code:
Private m_db As Database
Private m_wdApp As Object

Public Sub test()
    Set m_db = CurrentDb()
    Set m_wdApp = CreateObject("Word.Application")
    m_wdApp.Documents.Add
    m_wdApp.Visible = True
    Dim rs As Recordset
    Dim qd As QueryDef
    Set qd = m_db.QueryDefs("Query1")
    Set rs = qd.OpenRecordset      
    writeData rs
End Sub

Public Sub writeData(ByVal rs As Recordset)
    Dim doc As Object
    Dim value As String
    Set doc = m_wdApp.ActiveDocument
    Dim col As Integer
    Dim cols As Integer
    cols = rs.Fields.Count
    Do Until rs.EOF
        For col = 1 To cols
            If Len(rs(col - 1)) > 0 Then
                value = rs(col - 1)
                doc.Application.Selection.TypeText Text:=value
            End If
        Next col
        rs.MoveNext
    Loop
End Sub


Does someone has an idea? Thanks
 
I do not understand your code. What is going on with the Columns? You are only returning one field so that makes no sense to me.

Query 1:
"SELECT [description],[when] FROM tblTest;

Public Sub writeData(ByVal rs As Recordset)
Dim doc As Object
Dim varValue As variant
Set doc = m_wdApp.ActiveDocument
Do while not rs.EOF
varValue = rs!description & rs!when
if not trim(varValue & " ") = "" then
doc.Application.Selection.TypeText Text:=varValue
End If
rs.MoveNext
Loop
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top