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

Data Type Memo limited in query

Status
Not open for further replies.

benjamenus

Programmer
Dec 3, 2001
157
GB
Hi

I have a table with a field of Data Type 'Memo'. When I query this field, the results are limited to around 250 characters (some are cut off after 249 characters, some after 253, etc, etc). Is there a way to return the full text?
 
I suspect you are using a Group By query which restricts the memo text to 255 characters.

You wil need to re-write the query/report if you want to return the full text.

Mark...
 
Sorry, my apologies, I'm acutally not using GROUBY BY at all. The SQL is below. There are a couple of IN statements. Does this have the same effect?

SELECT DISTINCT t_Publishing.PublishingDate AS [Key Date], t_Company.CompanyName AS Company, t_Contact.ContactName AS Contact, t_Contact_1.ContactName AS [Supported by], t_Publishing.PublishingPurpose AS Summary, t_Publishing.PublishingInfo AS Notes
FROM t_Project INNER JOIN ((((t_Company INNER JOIN t_Contact ON t_Company.CompanyID = t_Contact.CompanyID) INNER JOIN (t_Contract INNER JOIN t_Contact AS t_Contact_1 ON t_Contract.LimehouseSupportID = t_Contact_1.ContactID) ON t_Company.CompanyID = t_Contract.CompanyID) INNER JOIN t_Publishing ON t_Company.CompanyID = t_Publishing.CompanyID) INNER JOIN t_ProjectContact ON t_Contact.ContactID = t_ProjectContact.ContactID) ON (t_Project.ProjectID = t_Publishing.ProjectID) AND (t_Project.ProjectID = t_ProjectContact.ProjectID)
WHERE (((t_Publishing.PublishingDate)>=[Enter start date dd/mm/yyyy]) AND ((t_Project.ProjectName) Like "*xxx") AND ((t_Contract.LimehouseSupportID) In (SELECT t_Contact.ContactID FROM t_Contact WHERE t_Contact.ContactName like "*" & [Enter Support Person's Name] & "*")))
ORDER BY t_Publishing.PublishingDate;

Opologies for the horrible formatting!
 
The culprit is the DISTINCT predicate.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PH

I thought I'd try an be clever be writing a query (without a 'distinct') that linked to the query with the 'distinct' - but that didn't work. Neither does using an IN statement that looks at the query with a 'distinct' so it seems that if there is a 'distinct' or 'group by' anywhere, then the memo field will be truncated.

Do you have any workarounds/solutions?

Cheers
 
writing a query (without a 'distinct') that linked to the query with the 'distinct'
Very good starting point.
Be sure to NOT select any memo field in the 'distinct' query !

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I have been sure not to select the Memo field in the DISTINCT query, but it still doesn't work. Would you mind looking over the SQL?

The first query selects the records with an ID of publishingId

The second query uses this and then pulls in the Memo field (PublishingInfo as Notes)

However, it is all still truncated

--- the two queries ---

r_ClientStatusReport_NoNotes

SELECT DISTINCT t_Publishing.PublishingID, t_Publishing.PublishingDate AS [Key Date], t_Company.CompanyName AS Company, t_Contact.ContactName AS Contact, t_Contact_1.ContactName AS [Supported by], t_Publishing.PublishingPurpose AS Summary
FROM t_Project INNER JOIN ((((t_Company INNER JOIN t_Contact ON t_Company.CompanyID = t_Contact.CompanyID) INNER JOIN (t_Contract INNER JOIN t_Contact AS t_Contact_1 ON t_Contract.LimehouseSupportID = t_Contact_1.ContactID) ON t_Company.CompanyID = t_Contract.CompanyID) INNER JOIN t_Publishing ON t_Company.CompanyID = t_Publishing.CompanyID) INNER JOIN t_ProjectContact ON t_Contact.ContactID = t_ProjectContact.ContactID) ON (t_Project.ProjectID = t_Publishing.ProjectID) AND (t_Project.ProjectID = t_ProjectContact.ProjectID)
WHERE (((t_Publishing.PublishingDate)>=[Enter start date dd/mm/yyyy]) AND ((t_Project.ProjectName) Like "*xxx") AND ((t_Contract.LimehouseSupportID) In (SELECT t_Contact.ContactID FROM t_Contact WHERE t_Contact.ContactName like "*" & [Enter Support Person's Name] & "*")))
ORDER BY t_Publishing.PublishingDate;

r_ClientStatusReport

SELECT r_ClientStatusReport_NoNotes.[Key Date], r_ClientStatusReport_NoNotes.Company, r_ClientStatusReport_NoNotes.Contact, r_ClientStatusReport_NoNotes.[Supported by], r_ClientStatusReport_NoNotes.Summary, t_Publishing.PublishingInfo AS Notes
FROM t_Publishing INNER JOIN r_ClientStatusReport_NoNotes ON t_Publishing.PublishingID = r_ClientStatusReport_NoNotes.PublishingID
ORDER BY r_ClientStatusReport_NoNotes.[Key Date], r_ClientStatusReport_NoNotes.Company, r_ClientStatusReport_NoNotes.Summary;
 
I think you need one query with everything EXCEPT the memo field and another query with just the PK and the memo field and then you join on the PK.


Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for anyone working with databases:
The Fundamentals of Relational Database Design
Understanding SQL Joi
 
If your output is going to be done in an access or crystal report or other report writer, an option might be to do you DISTINCT query for all the data EXCEPT the memo field and utilize a sub-report to pull in the memo using a link on the publisher ID.

Andy Baldwin

"Testing is the most overlooked programming language on the books!
 
Hi all

Thanks for your responses. A little more info for you...

So I can get Access to return all Memo data. It is in the export to Excel that it gets truncated. That is, if I export to HTML or RTF all of the data is there.

I'm using a macro to do the export.

Any ideas why the export to Excel is truncating it?
 
The truncating is probably a limitation with the amount of characters or data allowed in an excel Cell. I forget offhand what that limitation is.


Andy Baldwin

"Testing is the most overlooked programming language on the books!
 
Hi

It's being cut off at around 255 characters, but there is no such (small) limitation in Excel.

Thanks anyway
 
You may also want to try doing the export programmatically. You'll have to change the database location and the table name yourself.

Code:
Dim objExcelApp As Excel.Application
Dim xlsExcelSheet As Excel.Worksheet
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim col As Integer
Dim row As Integer
Dim strAccessDB As String
Dim FC As Integer
Private Sub Command0_Click()
    
    exportToExcel "C:\Development\AccessDB\Scratchpad.mdb", _
                "tblMemoOutput"

End Sub
Private Function exportToExcel(ByVal dbLocation As String, _
    ByVal tblName As String) As Boolean
   
   'Setup error handling
   On Error GoTo exportToExcel_Err
   
    exportToExcel = False
    
    ' Create the Excel application.
    Set objExcelApp = New Excel.Application
    objExcelApp.Visible = True

    ' Add the Excel spreadsheet.
    objExcelApp.Workbooks.Add
    
    ' Check for later versions.
    If Val(objExcelApp.Application.Version) >= 8 Then
        Set xlsExcelSheet = objExcelApp.Worksheets(1)
    Else
        Set xlsExcelSheet = objExcelApp
    End If

    ' Open the Access database.
    Set conn = New ADODB.Connection
    conn.ConnectionString = _
        "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=" & dbLocation & ";" & _
        "Persist Security Info=False"
    conn.Open

    ' Select the data.
    Set rs = conn.Execute(tblName, , _
        adCmdTableDirect)

    ' Make the column headers.
    
    FC = rs.Fields.Count - 1
    For col = 0 To FC
        xlsExcelSheet.Cells(1, col + 1) = rs.Fields(col).Name
    Next col

    ' Get data from the database and insert
    ' it into the spreadsheet.
    row = 2
    Do While Not rs.EOF
        For col = 0 To FC
            xlsExcelSheet.Cells(row, col + 1) = rs.Fields(col).Value
        Next col

        row = row + 1
        rs.MoveNext
    Loop
    
    'All is well
    exportToExcel = True
    
exportToExcel_Exit:
    'Cleanup code
    
    rs.Close
    Set rs = Nothing
    conn.Close
    Set conn = Nothing
    Set objExcelApp = Nothing
    
    Exit Function
    
exportToExcel_Err:
    exportToExcel = False
    'Alert the user that an error occurred
    MsgBox Err.Number & vbCrLf & Err.Description
    Resume exportToExcel_Exit

    
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top