Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics SL (Archived)

Generate copies of a label - Crystal Reports SL

(0) ShareShare
ReportReport
Posted on by 95

Hello, I use this code to generate a label, but I need to print a label number, 1 of 3, 2 of 3, 3 of 3 etc.

Call MessBox("¿Imprimir Etiqueta?", MB_YESNO, "Confirmación")
Response = MessResponse()

If Response = IDYES Then
      cad = " 11600/RUN " + PRMSEP + " 39codeT/FORMAT " + PRMSEP
      cad = cad & "{XAVw_EtiquetaProd.refnbr} = " + SParm(GetObjectValue("crefnbr")) + "/WHERE"
      cad = cad & PRMSEP + "/PSCRN"
      serr1 = Launch("ROI" + cad, 1, 1, 1)
End If

i try to add a parameter to the rpt but when trying to print it manually asks for the number of labels to print but that process must be automatic

try to pass the number of labels as a parameter but it only works for the sql statement and not for the RPT

If Response = IDYES Then

           cad = " 11600/RUN " + PRMSEP + " 39codeT/FORMAT " + PRMSEP
           cad = cad & "{Table1.refnbr} = " + SParm(GetObjectValue("crefnbr")) +  " and NumLabel="+ " SParm(GetObjectValue("NumLabels")) " +"/WHERE"
           cad = cad & PRMSEP + "/PSCRN"
           serr1 = Launch("ROI" + cad, 1, 1, 1)
      End If

I try using a loop to print the label but it does not work, ROI.exe crashes

dim NumLabel as integer

NumLabel = val(GetObjectValue("NumLabels"))

If Response = IDYES Then
      cad = " 11600/RUN " + PRMSEP + " 39codeT/FORMAT " + PRMSEP
      cad = cad & "{XAVw_EtiquetaProd.refnbr} = " + SParm(GetObjectValue("crefnbr")) + "/WHERE"
      cad = cad & PRMSEP + "/PSCRN"

      For VAR = 1 To NumLabel
           serr1 = Launch("ROI" + cad, 1, 1, 1)

     Next VAR


End If

 

thanks for your help

 

*This post is locked for comments

  • develop Profile Picture
    develop 95 on at
    RE: Generate copies of a label - Crystal Reports SL

    Hello Mr. Erich Strelow, as you say, use a function in SQL that returns the number of rows = the number of labels needed,

    When executing the view in sql it shows the total number of labels and the numbering 1 to N so that when generating the report in a normal way, it shows N numbered pages

    I appreciate your time very much

    have a nice day

  • Verified answer
    RE: Generate copies of a label - Crystal Reports SL

    If you are setup to print labels on a zebra-like printer, I have to warn you that CrystalReports is known to be pretty clumsy at this.

    Having said that, the results cardinality on Crystal Reports is always data-driven. You can print several copies, but that's of no use if you need to print the label sequence number.

    A dirty trick should be like this:

    1. Establish a stored procedure pre-process using the RunBefore feature.
    2. The stored procedure pre-process can then setup a loop in order to populate a temporary table (LabelRun sounds just right) with a row for every label you need.  You should use RI_ID as part of the key to avoid collisions.
    3. Set the temporary table as part of the join on your rpt. The label number must be a field on the temporary table.
    4. You should setup a RunAfter stored procedure to clean up the temporary table.

    The real dirty trick is how to actually pass the NumLabel parameter. You can abuse the WHERE clause:

    cad = cad & "{XAVw_EtiquetaProd.refnbr} = " + SParm(GetObjectValue("crefnbr")) + " and " + SParm(GetObjectValue("NumLabels")) + "=" + SParm(GetObjectValue("NumLabels")) + "/WHERE"

    You are reading right. If you need 4 labels, this will push a bogus "4=4" to the where clause. This can then be read by the RunBefore stored procedure from the RptRunTime.RI_WHERE field.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,703 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,433 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans