Results 1 to 10 of 10
  1. #1
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    100

    Question Unanswered: newLine in a memo field and print error

    The problem is that I want to write "newLines" in the field of the table I created to print the report. So, Chr(13) doesn't work, vbNewLine closes the field, I mean when I insert a vbNewLine in the field and I print, it finishes printing when it finds a vbNewLine.

    Moreover, It is giving this error:

    "The report name 'Print' you entered is mispelled or refers to a report that isn't open or doesn't exist"

    But anyway, the printer prints!!

    I am using this code to print:

    DoCmd.OpenReport ("Print")
    Reports("Print").Print
    DoCmd.Close acReport, "Print"

    I tried with other name for the report, same error.

    any help?

  2. #2
    Join Date
    Nov 2003
    Location
    Sussex, England
    Posts
    404

    New Line in a Memo Field

    I'm not sure this will help, but I had a similar problem with memo fields and queries. The string in the query was built up from several fields in different tables and I needed to put a line break inbetween some of the fields.

    The solution that worked for me was to set up a function - I called it get_CR() - and call that from the query.

    The field was something like:

    = [Firm] & get_Cr() & [street] & get_CR() & [city]

    the function - I think was on the lines of:

    Public function get_CR()

    get_CR()=chr$()13) & chr$(10)
    ' or vbCrLf
    end function

    Hope that helps.


  3. #3
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    100

    Unhappy

    Thank you, your combination of Chr does a right "newLine". But it stops to print after 3 lines of text. So I think the problem is the error that it gives me about "The report name 'Print' you entered is mispelled or refers to a report that isn't open or doesn't exist"

    And the combination of Chr takes less time than the vbNewLine, so the printer can print one line more before the error occurs.

    So, please, any help about the error of printing?

    Thanx

  4. #4
    Join Date
    Nov 2003
    Location
    Sussex, England
    Posts
    404

    Smile Report Print

    I've tried your code in Access 97 and no way will it work!

    Try:

    DoCmd.OpenReport "rptPrint", acViewNormal
    DoCmd.Close acReport, "rptPrint"

    The first line prints the report out - no problem, the second line closes it.
    If you put acViewPreview instead of acViewNormal the user will see the report on the scree and can print it out himself.

  5. #5
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    100
    I tried, it prints without error.
    But, hell!!! It's printing the same:

    ****** A REPORT OF SUPPLIERS *******

    Name: Supplier1


    And that's all!!!

    It must print the code, working and remark, also the rest of suppliers.

    I don't understand anything

  6. #6
    Join Date
    Mar 2004
    Location
    Glasgow, Scotland
    Posts
    107
    Look at post further up, memo field in report. Don't know if this helps...

  7. #7
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004
    Quote Originally Posted by pipeio
    I tried, it prints without error.
    But, hell!!! It's printing the same:

    ****** A REPORT OF SUPPLIERS *******

    Name: Supplier1


    And that's all!!!

    It must print the code, working and remark, also the rest of suppliers.

    I don't understand anything
    Pipeio,
    Could you Zip and Attach and Post a sample of your database. It's hard to get a real grasp as to what you really need, but I may be able to fix it for you if I can see it.

    Just trying to help,
    Bud....

  8. #8
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    100

    Unhappy

    Sorry but may database is around 2 MB in zip.

    This is the code I've been using:

    StrToPrint = " ****** A REPORT OF SUPPLIERS ****** " & Chr$(13) & Chr$(10) & Chr$(13) & Chr$(10)
    For Each x In SupplierList.ListItems
    StrToPrint = StrToPrint & "NAME: " & x.Subitems(1) & Chr$(13) & Chr$(10)
    StrToPrint = StrToPrint & "Code: " & x.Subitems(2) & Chr$(13) & Chr$(10)
    StrToPrint = StrToPrint & "Working: " & x.Subitems(3) & Chr$(13) & Chr$(10)
    StrToPrint = StrToPrint & "Remark: " & x.Subitems(4) & Chr$(13) & Chr$(10) & Chr$(13) & Chr$(10)

    Next

    Call PrintReport(StrToPrint)


    Public Function PrintReport(AString As Variant)

    Text1 = Left(AString, 65000)
    Text2 = ""
    Text3 = ""
    Text4 = ""
    Text5 = ""
    AStringLength = Len(AString)
    If AStringLength > 65000 Then Text2 = Mid(AString, 65001, 65000)
    If AStringLength > 130000 Then Text3 = Mid(AString, 130001, 65000)
    If AStringLength > 1950000 Then Text4 = Mid(AString, 195001, 65000)
    If AStringLength > 260000 Then Text5 = Mid(AString, 260001, 65000)

    SQL = "UPDATE Print SET Text1='" & Text1 & "'"
    If Text2 <> "" Then SQL = SQL & ", Text2='" & Text2 & "'"
    If Text3 <> "" Then SQL = SQL & ", Text3='" & Text3 & "'"
    If Text4 <> "" Then SQL = SQL & ", Text4='" & Text4 & "'"
    If Text5 <> "" Then SQL = SQL & ", Text5='" & Text5 & "'"
    SQL = SQL & " WHERE PrintPK=1"

    With DoCmd
    .SetWarnings False
    .RunSQL (SQL)
    .SetWarnings True
    End With


    DoCmd.OpenReport "Print", acViewNormal
    DoCmd.Close acReport, "Print"

    End Function

    The Print table has the right string in Text1 field, all the lines with all the "newLines".
    But when I print only prints the like the first 4 lines.

    It's very weird.

  9. #9
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    100

    Thumbs up hehehe

    Ok people, sorry I am very stupid. It was the can grow and can shrink.

    So stupid ...

  10. #10
    Join Date
    Nov 2003
    Location
    Sussex, England
    Posts
    404

    Smile Can grow can shrink

    Let's face it - it's things like this that the beat the best of us at times. I know I'm all too often looking for a really complex answer when the solution is staring me in the face.

    Glad you've got it sorted.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •