Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Access Query Cutting off Memo Text

Posted on 2014-12-02
6
Medium Priority
?
687 Views
Last Modified: 2014-12-02
I have a Query that is organized by “Select Distinct Top 1”

Access is Ternicating (sp?) the records displayed in the Query and cutting the text off at 255 characters.

I created a Module with the following code—but it doesn’t seem to be working.

Am I missing something here?  Can anyone think of what I’m doing wrong?



Public Function LookupMemo( _
  ByVal strSource As String, _
  ByVal strFieldID As String, _
  ByVal strFieldMemo As String, _
  ByRef lngID As Long, _
  ByRef varMemo As Variant) _
  As String
 
  Const clngStrLen  As Long = &H8000&

  Dim strExpr       As String
  Dim strDomain     As String
  Dim strCriteria   As String
  Dim strMemo       As String
  Dim lngLen        As Long
 
  On Error GoTo Exit_LookupMemo

  If Not IsNull(varMemo) Then
    lngLen = Len(varMemo)
    If lngLen < clngStrLen Then
     
      strMemo = varMemo
    ElseIf Len(strSource) > 0 And Len(strFieldID) > 0 And Len(strFieldMemo) > 0 Then
     
      strExpr = strFieldMemo
      strDomain = strSource
      strCriteria = strFieldID & " = " & lngID & ""
      strMemo = vbNullString & DLookup(strExpr, strDomain, strCriteria)
    End If
  Else
   
  End If
 
  LookupMemo = strMemo

Exit_LookupMemo:
  Exit Function
 
Err_LookupMemo:
 
  Resume Exit_LookupMemo
 
End Function
0
Comment
Question by:mdstalla
[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
  • 4
  • 2
6 Comments
 
LVL 26

Expert Comment

by:Nick67
ID: 40477273
Am I missing something here?  Can anyone think of what I’m doing wrong?
Memo text is evil.
There are many, many ways and times that it gets truncated, and that is an expected result.
http://allenbrowne.com/ser-63.html
DLookup(strExpr, strDomain, strCriteria)
is one of them.

What are you looking to accomplish?
0
 

Author Comment

by:mdstalla
ID: 40477282
I just want to be able to keep the Select Top 1 ordering-- but not have my memo fields get limited to 255 Characters.
0
 
LVL 26

Accepted Solution

by:
Nick67 earned 2000 total points
ID: 40477286
You can do a two step dosie-do
Take your Select Top 1 and remove the memo field

Then create a new query using your Top 1 saved query as one table, and the memo field table as the other.
Create an appropriate join
Select all the fields you need, including the memo.

See if that works for you
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 26

Expert Comment

by:Nick67
ID: 40477316
Recordset code is less likely to truncate
You can try this

Public Function LookupMemo( _
   ByVal strSource As String, _
   ByVal strFieldID As String, _
   ByVal strFieldMemo As String, _
   ByRef lngID As Long, _
   ByRef varMemo As Variant) _
   As String

   Dim db as Database
   Set rs = CurrentDb.OpenRecordset("select " & strFieldMemo & " from " & strSource & " where " &  strFieldID & " = " & lngID & "", dbOpenDynaSet)
   if rs.RecordCount <> 0 then  
       LookupMemo = rs.fields(strExpr)
   Else
       LookupMemo = ""
   End If
   rs.close
   Set rs = nothing
 End Function 

Open in new window

0
 

Author Closing Comment

by:mdstalla
ID: 40477470
Yah, Nick-- It's strange but the Parent Query doesn't cut the Memo-record off at 255 characters as long as the record comes from a Child Query rather than direct from a Table.  Very strange.

Anyway, your trick worked. Thanks for the tip.
0
 
LVL 26

Expert Comment

by:Nick67
ID: 40477487
If you remember "Memo text is evil" you can google up most of the ways to work around it.
Or the times when you are going to be SOL
Like putting memo text in Excel cells, where 255 will display in the cell, 1024 in the formula bar, and the rest will get truncated.

Glad to be of service
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

730 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