473,405 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Concatenate Function truncates memo field datas

I have set Allen Browne Concatenate function in my DB. The function combines muchtext multiple rows and yields truncated results.

Truncated field: tum_bulgu_durum_satir.[Tüm Bulgu Durumları]

How can i avoid truncation. My database can be downloaded from following link:

[Moderator edit{removed external link}]

Thank you in advance


Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Public Function ConcatRelated(strField As String, _
  4.     strTable As String, _
  5.     Optional strWhere As String, _
  6.     Optional strOrderBy As String, _
  7.     Optional strSeparator = ", ") As Variant
  8. On Error GoTo Err_Handler
  9.     'Purpose:   Generate a concatenated string of related records.
  10.     'Return:    String variant, or Null if no matches.
  11.     'Arguments: strField = name of field to get results from and concatenate.
  12.     '           strTable = name of a table or query.
  13.     '           strWhere = WHERE clause to choose the right values.
  14.     '           strOrderBy = ORDER BY clause, for sorting the values.
  15.     '           strSeparator = characters to use between the concatenated values.
  16.     'Notes:     1. Use square brackets around field/table names with spaces or odd characters.
  17.     '           2. strField can be a Multi-valued field (A2007 and later), but strOrderBy cannot.
  18.     '           3. Nulls are omitted, zero-length strings (ZLSs) are returned as ZLSs.
  19.     '           4. Returning more than 255 characters to a recordset triggers this Access bug:
  20.     '               http://allenbrowne.com/bug-16.html
  21.     Dim rs As DAO.Recordset         'Related records
  22.     Dim rsMV As DAO.Recordset       'Multi-valued field recordset
  23.     Dim strSql As String            'SQL statement
  24.     Dim strOut As String            'Output string to concatenate to.
  25.     Dim lngLen As Long              'Length of string.
  26.     Dim bIsMultiValue As Boolean    'Flag if strField is a multi-valued field.
  27.  
  28.     'Initialize to Null
  29.     ConcatRelated = Null
  30.  
  31.     'Build SQL string, and get the records.
  32.     strSql = "SELECT " & strField & " FROM " & strTable
  33.     If strWhere <> vbNullString Then
  34.         strSql = strSql & " WHERE " & strWhere
  35.     End If
  36.     If strOrderBy <> vbNullString Then
  37.         strSql = strSql & " ORDER BY " & strOrderBy
  38.     End If
  39.     Set rs = DBEngine(0)(0).OpenRecordset(strSql, dbOpenDynaset)
  40.     'Determine if the requested field is multi-valued (Type is above 100.)
  41.     bIsMultiValue = (rs(0).Type > 100)
  42.  
  43.     'Loop through the matching records
  44.     Do While Not rs.EOF
  45.         If bIsMultiValue Then
  46.             'For multi-valued field, loop through the values
  47.             Set rsMV = rs(0).Value
  48.             Do While Not rsMV.EOF
  49.                 If Not IsNull(rsMV(0)) Then
  50.                     strOut = strOut & rsMV(0) & strSeparator
  51.                 End If
  52.                 rsMV.MoveNext
  53.             Loop
  54.             Set rsMV = Nothing
  55.         ElseIf Not IsNull(rs(0)) Then
  56.             strOut = strOut & rs(0) & strSeparator
  57.         End If
  58.         rs.MoveNext
  59.     Loop
  60.     rs.Close
  61.  
  62.     'Return the string without the trailing separator.
  63.     lngLen = Len(strOut) - Len(strSeparator)
  64.     If lngLen > 0 Then
  65.         ConcatRelated = Left(strOut, lngLen)
  66.     End If
  67.  
  68. Exit_Handler:
  69.     'Clean up
  70.     Set rsMV = Nothing
  71.     Set rs = Nothing
  72.     Exit Function
  73.  
  74. Err_Handler:
  75.     MsgBox "Error " & Err.Number & ": " & Err.Description, vbExclamation, "ConcatRelated()"
  76.     Resume Exit_Handler
  77. End Function
Aug 23 '13 #1
4 2719
nico5038
3,080 Expert 2GB
For this you can create a workaround by using a function to build a result table like:
Expand|Select|Wrap|Line Numbers
  1. Function fncFillConcat()
  2.  
  3. Dim rsI As DAO.Recordset
  4. Dim rsI2 As DAO.Recordset
  5. Dim rsO As DAO.Recordset
  6. Dim strTitle As String
  7. Dim strTitleOld As String
  8.  
  9. ' init table
  10. CurrentDb.Execute ("Delete * from tblBulgu_Durumu_Result")
  11.  
  12. ' Select the unique combinations of [Bulgu Kodu] and [Durum Tarihi]
  13. Set rsI = CurrentDb.OpenRecordset("Select Distinct  [Bulgu Kodu], [Durum Yazan Denetçi] from [Bulgu_Durumu]")
  14. Set rsO = CurrentDb.OpenRecordset("tblBulgu_Durumu_Result")
  15.  
  16. ' Loop to add one row for each IDArtikkel
  17. While Not rsI.EOF
  18.     rsO.AddNew
  19.     rsO![Bulgu Kodu] = rsI![Bulgu Kodu]
  20.     'now concatenate all fields
  21.     Set rsI2 = CurrentDb.OpenRecordset("Select Bulgu_Durumu.[Durum Tarihi] & '|' & Bulgu_Durumu.[Durum Yazan Denetçi] & ' :' as Title , Durum FROM Bulgu_Durumu where [Bulgu Kodu]='" & rsI![Bulgu Kodu] & "' and [Durum Yazan Denetçi]='" & rsI![Durum Yazan Denetçi] & "'")
  22.     'first place title
  23.     strTitle = rsI2![Title] & vbCrLf
  24.     strTitleOld = rsI2![Title] & vbCrLf
  25.     rsO![Durum] = strTitle
  26.     While Not rsI2.EOF
  27.        'Check for title change, when changed, add title
  28.        strTitle = rsI2![Title] & vbCrLf
  29.        If strTitle <> strTitleOld Then
  30.           strTitleOld = strTitle
  31.           rsO![Durum] = rsO![Durum] & vbCrLf & strTitle
  32.        End If
  33.        rsO![Durum] = rsO![Durum] & vbCrLf & rsI2![Durum]
  34.        rsI2.MoveNext
  35.     Wend
  36.     rsO.Update
  37.     rsI.MoveNext
  38. Wend
  39.  
  40.  
  41. End Function
  42.  
Just define table "tblBulgu_Durumu_Result" with the fields:
Bulgu Kodu (Text)
Durum (Memo)

and run the function to fill this table.

Nic;o)
Aug 23 '13 #2
Hello Nico,

Thank you for your response.

The code works but it duplicates some [Bulgu Kodu] data.
[Bulgu Kodu] should be unique.

I believe it calculates unique combination as [Bulgu Kodu] & [Durum Yazan Denetçi]. I couldn't fix. Can you look line 13.
Aug 23 '13 #3
nico5038
3,080 Expert 2GB
Oops, try:
Expand|Select|Wrap|Line Numbers
  1. ' Select the unique values of [Bulgu Kodu]
  2. Set rsI = CurrentDb.OpenRecordset("Select Distinct  [Bulgu Kodu]  from [Bulgu_Durumu]")
  3.  
Nic;o)
Aug 23 '13 #4
Thank you very much. Everything works perfect.
Aug 23 '13 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: GorDon | last post by:
Hi, I have a report based on a query. The query grabs a memo field from my main table, yet when I display the memo field in the report it truncates the memo field (the field needs to hold more...
4
by: Anna | last post by:
Hi all, I have a query in ASP.NET that selects text from a memo field in Access (among other things). The query appears to be truncating the text at 255 characters. I've done a little research...
3
by: Laurie | last post by:
I am using Automation in Access 2003 to open a Word Document and fill in some values using bookmarks. It all works perfectly except for one section. I am filling in some values in a previously...
2
by: lesperancer | last post by:
I've read all the posts, but nothing works I've got a table with an ID field and a memo field one record in the table, with the memo field having 322 chars I open the table, and then use the...
2
by: jacoballen | last post by:
I have a query that combines the results of three related tables. The memo fields are truncated to 255 characters, but I need all the information in them. I'm aware that removing code such as...
2
by: cherylwalsh35 | last post by:
I am working in access - using a select Query. I am including a memo field. The table has all of the data in the memo field displayed - however when I run a select query and include the memo...
15
by: sara | last post by:
I have a Memo field in a table to hold notes from a conversation a social worker has had with a client (this is for a non-profit). If the user needs to update the memo field, I need to find the...
2
by: mccalla | last post by:
Hi, I am very new to MS Access. I have inherited an existing app which was done in MS Access 2003. In this app, there is a report which contains a memo field. There are no formats, functions,...
0
by: johnvonc | last post by:
I am using Access 2003, and trying to Export query results in code to a csv file. I am using DoCmd.TransferText. When I run the query, there are two memo fields: Description and...
0
by: munkee | last post by:
Right this is purely an idea, I have an infopath form which I wish to use to populate my access database. The database and form require the usage of memo fields, basically long text over 255...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.