Method Community

 

Method Report Designer - Creating a Variable

Last post 10-30-2015 12:24 PM by l.brandow. 14 replies.
Page 1 of 1 (15 items)
Sort Posts: Previous Next
  • 04-25-2012 6:32 AM

    Method Report Designer - Creating a Variable

    I am a long-time Crystal Reports user and am learning the Method Report Designer.  

    I am customizing the Estimate form and want to put a Ship To Address on the form.  I copied and modified the script for the Bill To Address, but I don't know how to declare the xrShiptoAddress variable for the new script.  It isn't declared within the script itself...

    I would appreciate any help you could offer!  

    Thanks!

    Carol

  • 04-25-2012 9:43 AM In reply to

    Re: Method Report Designer - Creating a Variable

    Answer

    Hi CarolOliver,

    First up, welcome to Method.

    CarolOliver:
    It isn't declared within the script itself...

    It does get declared in the script on the 4th line: xrShipAddress.Text.  If you use xrShipAddress as the variable name you also need to update the property grid > design (name) field to the same name: xrShipAddress.  See my screenshot here.

    Please post back if you have any problems.

    ~C

  • 04-25-2012 10:27 AM In reply to

    Re: Method Report Designer - Creating a Variable

    Answer

    Chad,

    Fabulous!  Thanks so much.  

    Yes, I dive in fearlessly -- I learn best that way.  Big Smile

    My only problem now is that the carriage return (hard enter) is not working.  Here is my script -- It's almost identical to the Bill to address except that I renamed the string variable because I didn't know if I could use the same variable name twice.

     

     

    Private Sub OnBeforePrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs)

    'Create a carriage return variable, for simplicity

    dim aNewLine as String = Microsoft.VisualBasic.ChrW(13) + Microsoft.VisualBasic.ChrW(10)


    xrShipAdd.Text = GetCurrentColumnValue("ShipAddressAddr1") _

    + Microsoft.VisualBasic.Interaction.IIf(GetCurrentColumnValue("ShipAddressAddr2") <> String.Empty,aNewLine + GetCurrentColumnValue("ShipAddressAddr2"),"") _

    + Microsoft.VisualBasic.Interaction.IIf(GetCurrentColumnValue("ShipAddressAddr3") <> String.Empty,aNewLine + GetCurrentColumnValue("ShipAddressAddr3"),"") _

    + Microsoft.VisualBasic.Interaction.IIf(GetCurrentColumnValue("ShipAddressCity") <> String.Empty,aNewLine + GetCurrentColumnValue("ShipAddressCity") + ", " + GetCurrentColumnValue("ShipAddressState") + " " + GetCurrentColumnValue("ShipAddressPostalCode"),"") _

    + Microsoft.VisualBasic.Interaction.IIf(GetCurrentColumnValue("ShipAddressCountry") <> String.Empty,aNewLine + GetCurrentColumnValue("ShipAddressCountry"),"") 


    End Sub

     

     

    Also, this is so similar to VBA.  Can you recommend a book on scripts?  

    Thanks again!!!

    Carol

  • 04-25-2012 10:47 AM In reply to

    Re: Method Report Designer - Creating a Variable

    Answer

    Well, I AM embarassed!!!!

    The field property "Multiline" was not set to YES.

    And I also discovered that I can re-declare a string variable with the same name.

    Thanks!

    Carol

  • 04-25-2012 3:02 PM In reply to

    Re: Method Report Designer - Creating a Variable

    Answer

    Another tip I just got from my co-worker here is if you use CType(sender, XRLabel).Text as your variable name it references the current label you're writing the script in.

    Happy Methoding

    ~C

  • 04-25-2012 3:15 PM In reply to

    Re: Method Report Designer - Creating a Variable

    Thanks SO much.

    Carol

  • 06-17-2014 4:05 PM In reply to

    • l.brandow
    • Top 25 Contributor
    • Joined on 03-18-2011
    • American Fork, Utah
    • Posts 243

    Re: Method Report Designer - Creating a Variable

    I added a few fields to the Sales Order table and Sales Order screen. I'd like to add the same fields to the ship to address on the Sales Order template as wellI tried adding 

    them to the script like this:

    Private Sub OnBeforePrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs)
    'Create a carriage return variable, for simplicity
    dim sNewLine as String = Microsoft.VisualBasic.ChrW(13) + Microsoft.VisualBasic.ChrW(10)

    xrShipAddress.Text = GetCurrentColumnValue("ShipAddressAddr1") _
    + Microsoft.VisualBasic.Interaction.IIf(GetCurrentColumnValue("ShipAddressAddr2") <> String.Empty,sNewLine + GetCurrentColumnValue("ShipAddressAddr2"),"") _
    + Microsoft.VisualBasic.Interaction.IIf(GetCurrentColumnValue("ShipAddressAddr3") <> String.Empty,sNewLine + GetCurrentColumnValue("ShipAddressAddr3"),"") _
    + Microsoft.VisualBasic.Interaction.IIf(GetCurrentColumnValue("ShipAddressCity") <> String.Empty,sNewLine + GetCurrentColumnValue("ShipAddressCity") + ", " + GetCurrentColumnValue("ShipAddressState") + " " + GetCurrentColumnValue("ShipAddressPostalCode"),"") _
    + Microsoft.VisualBasic.Interaction.IIf(GetCurrentColumnValue("ShipAddressCountry") <> String.Empty,sNewLine + GetCurrentColumnValue("ShipAddressCountry"),"") 
    + Microsoft.VisualBasic.Interaction.IIf(GetCurrentColumnValue("aaContactName") <> String.Empty,sNewLine + GetCurrentColumnValue("aaContactName"),"") 
    + Microsoft.VisualBasic.Interaction.IIf(GetCurrentColumnValue("aaContactEmail") <> String.Empty,sNewLine + GetCurrentColumnValue("aaContactEmail"),"") 
    + Microsoft.VisualBasic.Interaction.IIf(GetCurrentColumnValue("aaContatPhone") <> String.Empty,sNewLine + GetCurrentColumnValue("aaContactPhone"),"")

    End Sub

    When I try a print preview I get this error:

    There are following errors in scripts(s):

    xrShipAddress.OnBeforePrint, Line 10: error BC30035: Syntax error.

    xrShipAddress.OnBeforePrint, Line 11: error BC30035: Syntax error.

    xrShipAddress.OnBeforePrint, Line 3: error BC30035: Syntax error.

    With this information can someone possibly see what I'm doing wrong? Any help would be great.

    Thanks!


    Lance Brandow
    Method Customization Expert
    Brandow Consulting
    (801) 687-3254
  • 06-23-2014 9:42 AM In reply to

    • fran
    • Top 25 Contributor
    • Joined on 02-07-2009
    • Mountain View
    • Posts 453

    Re: Method Report Designer - Creating a Variable

    Hey Lance,

    I can't speak to your script, but add these elements to my Sales Orders templates all the time. I add them as fields beneath the address box so that I can add labels, like "name, email,phone"...They aren't quite the same as an address.

    Fran

    Fran Reed
    FreedUp Solutions
    Intuit Solution Provider
    Advanced Certified Quickbooks ProAdvisor
    Advanced Method Solution Provider
  • 07-01-2014 10:17 AM In reply to

    Re: Method Report Designer - Creating a Variable

    Hello Lance,

        Sorry for the late reply.  I do not see any typos in the code.  I did a quick search for the error and you may have an issue with spacing.  Try taking away spaces or adding spaces.  It gives three lines where the error is occurring., but I can't tell the line numbering from your post.  I would recommend taking away parts of the code and trying to find exactly what line it is erroring out on.

       Thanks Fran for your response.   It looks like Lance's code is dealing with spacing and blank fields for address.  I have seen this type of code before that eliminates dead space in addresses.

    Greg

    Greg Bilous
    Community Support Specialist
    Method Integration
    g.bilous@method.me
    Toll Free: 1.888.925.6238
    Local and overseas: 416.847.0400 ex.756
    Fax: 416.640.6027
  • 08-11-2014 5:07 PM In reply to

    • l.brandow
    • Top 25 Contributor
    • Joined on 03-18-2011
    • American Fork, Utah
    • Posts 243

    Re: Method Report Designer - Creating a Variable

    Thanks Fran! It's good to hear from you. I'm trying to avoid that route. Let 's hope I can get this working.


    Hey Greg,

    Line 3 is:    dim sNewLine as String = Microsoft.VisualBasic.ChrW(13) + Microsoft.VisualBasic.ChrW(10)
    Line 10 is:  + Microsoft.VisualBasic.Interaction.IIf(GetCurrentColumnValue("aaContactName") <> String.Empty,sNewLine + GetCurrentColumnValue("aaContactName"),"")
    Line 11 is:  + Microsoft.VisualBasic.Interaction.IIf(GetCurrentColumnValue("aaContactEmail") <> String.Empty,sNewLine + GetCurrentColumnValue("aaContactEmail"),"")

    I found an extra space at the end of lines 10 and 11, so I deleted them; saved and ran the print preview again. I'm still getting the same error message. What kind of spacing or blank field should I be looking for?

    Thanks,

    Lance Brandow
    Method Customization Expert
    Brandow Consulting
    (801) 687-3254
  • 08-12-2014 8:44 AM In reply to

    Re: Method Report Designer - Creating a Variable

    Hey Lance,

      It looks like you found some stray spaces.  This must not have been the issue.  I would recommend going with just the first couple of lines.  Generate the report and see if it work.s.  Then subsequently add another line of the equation.  See if this pinpoints where the error is occurring.

    Greg

    Greg Bilous
    Community Support Specialist
    Method Integration
    g.bilous@method.me
    Toll Free: 1.888.925.6238
    Local and overseas: 416.847.0400 ex.756
    Fax: 416.640.6027
  • 08-12-2014 9:12 AM In reply to

    Re: Method Report Designer - Creating a Variable

    Hello Lance,

      I have a hot new lead.  You are missing underscores, " _ " in your equation.  When you have to carry the equation to a new line, you need underscores to tell the program it's continuing on the next line.

    eg.    a + b

    Correct: 

    a_

    + b

    Incorrect:

    a

    + b

    Let me know if this works.

    Greg

    Greg Bilous
    Community Support Specialist
    Method Integration
    g.bilous@method.me
    Toll Free: 1.888.925.6238
    Local and overseas: 416.847.0400 ex.756
    Fax: 416.640.6027
  • 08-12-2014 9:22 AM In reply to

    • l.brandow
    • Top 25 Contributor
    • Joined on 03-18-2011
    • American Fork, Utah
    • Posts 243

    Re: Method Report Designer - Creating a Variable

    Okay that helped. I'm not getting an error message any more. For some reason, however, it's not pulling my custom fields. I'm trouble shooting that now.

    Lance Brandow
    Method Customization Expert
    Brandow Consulting
    (801) 687-3254
  • 08-12-2014 9:24 AM In reply to

    • l.brandow
    • Top 25 Contributor
    • Joined on 03-18-2011
    • American Fork, Utah
    • Posts 243

    Re: Method Report Designer - Creating a Variable

    Okay, It worked! Thank you very much!

    Lance Brandow
    Method Customization Expert
    Brandow Consulting
    (801) 687-3254
  • 10-30-2015 12:24 PM In reply to

    • l.brandow
    • Top 25 Contributor
    • Joined on 03-18-2011
    • American Fork, Utah
    • Posts 243

    Re: Method Report Designer - Creating a Variable

    Forums are great. I just used this again. 

    Lance Brandow
    Method Customization Expert
    Brandow Consulting
    (801) 687-3254
Page 1 of 1 (15 items)