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
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
Does someone has an idea? Thanks
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