SSRS access built-in functions from report vb code












0















I'm working on create a multilingual SSRS report for SQL Server 2008R2.
To do that without external code and only get translation from DB, I need to use Lookup() built-in function in the section code of the report.

I have the following expression for textbox:



=LOOKUP("Rpt_0_Hello", Fields!Token.Value, Fields!Translation.Value, "DS_Translation")




The goal is to reduce the complexity of expression for the textbox translation. I would like to get to the expression:



=Code.TrasT("Rpt_0_Hello")


I try to write a VB function like this:



Public Function TransT( Token as String )
Lookup( Token
,Report.Fields!Token.Value
,Report.Fields!Translation.Value
,"DS_Translation")
End Function


This code generate an error of "[BC30451]'Lookup' is not declared.".
I found on the web to use "Report" object to get Report element like Fields.

Is there a way to reference "Lookup()"?










share|improve this question

























  • This is not VBScript. Is it VBA perhaps? Please use the appropriate tags.

    – Geert Bellekens
    Nov 27 '18 at 12:06













  • This is not VBA because there's not based on a strong Object model like excel, but it's a simple VB interpreter with syntax not well defined.

    – GLNebiacolombo
    Nov 27 '18 at 13:11











  • something like Token as String is not valid VBScript syntax, so if it works I guess it must be VBA, or VB.Net or just plain VB or.... VBA still seems like the most likely candidate though.

    – Geert Bellekens
    Nov 27 '18 at 13:59











  • The Lookup function (docs.microsoft.com/en-us/sql/reporting-services/report-design/…) can be used used in an expression. See this article for some examples - red-gate.com/simple-talk/sql/reporting-services/… Try seeing expression of a cell in table to this =Lookup( Token ,Report.Fields!Token.Value, Report.Fields!Translation.Value, ,"DS_Translation")

    – BobF
    Nov 27 '18 at 19:20













  • I know the normal use of Lookup on Expression but I ask for to use them on Code section to reduce the complexity of expression for the textbox translation

    – GLNebiacolombo
    Nov 28 '18 at 8:11
















0















I'm working on create a multilingual SSRS report for SQL Server 2008R2.
To do that without external code and only get translation from DB, I need to use Lookup() built-in function in the section code of the report.

I have the following expression for textbox:



=LOOKUP("Rpt_0_Hello", Fields!Token.Value, Fields!Translation.Value, "DS_Translation")




The goal is to reduce the complexity of expression for the textbox translation. I would like to get to the expression:



=Code.TrasT("Rpt_0_Hello")


I try to write a VB function like this:



Public Function TransT( Token as String )
Lookup( Token
,Report.Fields!Token.Value
,Report.Fields!Translation.Value
,"DS_Translation")
End Function


This code generate an error of "[BC30451]'Lookup' is not declared.".
I found on the web to use "Report" object to get Report element like Fields.

Is there a way to reference "Lookup()"?










share|improve this question

























  • This is not VBScript. Is it VBA perhaps? Please use the appropriate tags.

    – Geert Bellekens
    Nov 27 '18 at 12:06













  • This is not VBA because there's not based on a strong Object model like excel, but it's a simple VB interpreter with syntax not well defined.

    – GLNebiacolombo
    Nov 27 '18 at 13:11











  • something like Token as String is not valid VBScript syntax, so if it works I guess it must be VBA, or VB.Net or just plain VB or.... VBA still seems like the most likely candidate though.

    – Geert Bellekens
    Nov 27 '18 at 13:59











  • The Lookup function (docs.microsoft.com/en-us/sql/reporting-services/report-design/…) can be used used in an expression. See this article for some examples - red-gate.com/simple-talk/sql/reporting-services/… Try seeing expression of a cell in table to this =Lookup( Token ,Report.Fields!Token.Value, Report.Fields!Translation.Value, ,"DS_Translation")

    – BobF
    Nov 27 '18 at 19:20













  • I know the normal use of Lookup on Expression but I ask for to use them on Code section to reduce the complexity of expression for the textbox translation

    – GLNebiacolombo
    Nov 28 '18 at 8:11














0












0








0








I'm working on create a multilingual SSRS report for SQL Server 2008R2.
To do that without external code and only get translation from DB, I need to use Lookup() built-in function in the section code of the report.

I have the following expression for textbox:



=LOOKUP("Rpt_0_Hello", Fields!Token.Value, Fields!Translation.Value, "DS_Translation")




The goal is to reduce the complexity of expression for the textbox translation. I would like to get to the expression:



=Code.TrasT("Rpt_0_Hello")


I try to write a VB function like this:



Public Function TransT( Token as String )
Lookup( Token
,Report.Fields!Token.Value
,Report.Fields!Translation.Value
,"DS_Translation")
End Function


This code generate an error of "[BC30451]'Lookup' is not declared.".
I found on the web to use "Report" object to get Report element like Fields.

Is there a way to reference "Lookup()"?










share|improve this question
















I'm working on create a multilingual SSRS report for SQL Server 2008R2.
To do that without external code and only get translation from DB, I need to use Lookup() built-in function in the section code of the report.

I have the following expression for textbox:



=LOOKUP("Rpt_0_Hello", Fields!Token.Value, Fields!Translation.Value, "DS_Translation")




The goal is to reduce the complexity of expression for the textbox translation. I would like to get to the expression:



=Code.TrasT("Rpt_0_Hello")


I try to write a VB function like this:



Public Function TransT( Token as String )
Lookup( Token
,Report.Fields!Token.Value
,Report.Fields!Translation.Value
,"DS_Translation")
End Function


This code generate an error of "[BC30451]'Lookup' is not declared.".
I found on the web to use "Report" object to get Report element like Fields.

Is there a way to reference "Lookup()"?







sql-server vba reporting-services ssrs-2008-r2






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 7 '18 at 19:10







GLNebiacolombo

















asked Nov 27 '18 at 11:53









GLNebiacolomboGLNebiacolombo

11




11













  • This is not VBScript. Is it VBA perhaps? Please use the appropriate tags.

    – Geert Bellekens
    Nov 27 '18 at 12:06













  • This is not VBA because there's not based on a strong Object model like excel, but it's a simple VB interpreter with syntax not well defined.

    – GLNebiacolombo
    Nov 27 '18 at 13:11











  • something like Token as String is not valid VBScript syntax, so if it works I guess it must be VBA, or VB.Net or just plain VB or.... VBA still seems like the most likely candidate though.

    – Geert Bellekens
    Nov 27 '18 at 13:59











  • The Lookup function (docs.microsoft.com/en-us/sql/reporting-services/report-design/…) can be used used in an expression. See this article for some examples - red-gate.com/simple-talk/sql/reporting-services/… Try seeing expression of a cell in table to this =Lookup( Token ,Report.Fields!Token.Value, Report.Fields!Translation.Value, ,"DS_Translation")

    – BobF
    Nov 27 '18 at 19:20













  • I know the normal use of Lookup on Expression but I ask for to use them on Code section to reduce the complexity of expression for the textbox translation

    – GLNebiacolombo
    Nov 28 '18 at 8:11



















  • This is not VBScript. Is it VBA perhaps? Please use the appropriate tags.

    – Geert Bellekens
    Nov 27 '18 at 12:06













  • This is not VBA because there's not based on a strong Object model like excel, but it's a simple VB interpreter with syntax not well defined.

    – GLNebiacolombo
    Nov 27 '18 at 13:11











  • something like Token as String is not valid VBScript syntax, so if it works I guess it must be VBA, or VB.Net or just plain VB or.... VBA still seems like the most likely candidate though.

    – Geert Bellekens
    Nov 27 '18 at 13:59











  • The Lookup function (docs.microsoft.com/en-us/sql/reporting-services/report-design/…) can be used used in an expression. See this article for some examples - red-gate.com/simple-talk/sql/reporting-services/… Try seeing expression of a cell in table to this =Lookup( Token ,Report.Fields!Token.Value, Report.Fields!Translation.Value, ,"DS_Translation")

    – BobF
    Nov 27 '18 at 19:20













  • I know the normal use of Lookup on Expression but I ask for to use them on Code section to reduce the complexity of expression for the textbox translation

    – GLNebiacolombo
    Nov 28 '18 at 8:11

















This is not VBScript. Is it VBA perhaps? Please use the appropriate tags.

– Geert Bellekens
Nov 27 '18 at 12:06







This is not VBScript. Is it VBA perhaps? Please use the appropriate tags.

– Geert Bellekens
Nov 27 '18 at 12:06















This is not VBA because there's not based on a strong Object model like excel, but it's a simple VB interpreter with syntax not well defined.

– GLNebiacolombo
Nov 27 '18 at 13:11





This is not VBA because there's not based on a strong Object model like excel, but it's a simple VB interpreter with syntax not well defined.

– GLNebiacolombo
Nov 27 '18 at 13:11













something like Token as String is not valid VBScript syntax, so if it works I guess it must be VBA, or VB.Net or just plain VB or.... VBA still seems like the most likely candidate though.

– Geert Bellekens
Nov 27 '18 at 13:59





something like Token as String is not valid VBScript syntax, so if it works I guess it must be VBA, or VB.Net or just plain VB or.... VBA still seems like the most likely candidate though.

– Geert Bellekens
Nov 27 '18 at 13:59













The Lookup function (docs.microsoft.com/en-us/sql/reporting-services/report-design/…) can be used used in an expression. See this article for some examples - red-gate.com/simple-talk/sql/reporting-services/… Try seeing expression of a cell in table to this =Lookup( Token ,Report.Fields!Token.Value, Report.Fields!Translation.Value, ,"DS_Translation")

– BobF
Nov 27 '18 at 19:20







The Lookup function (docs.microsoft.com/en-us/sql/reporting-services/report-design/…) can be used used in an expression. See this article for some examples - red-gate.com/simple-talk/sql/reporting-services/… Try seeing expression of a cell in table to this =Lookup( Token ,Report.Fields!Token.Value, Report.Fields!Translation.Value, ,"DS_Translation")

– BobF
Nov 27 '18 at 19:20















I know the normal use of Lookup on Expression but I ask for to use them on Code section to reduce the complexity of expression for the textbox translation

– GLNebiacolombo
Nov 28 '18 at 8:11





I know the normal use of Lookup on Expression but I ask for to use them on Code section to reduce the complexity of expression for the textbox translation

– GLNebiacolombo
Nov 28 '18 at 8:11












3 Answers
3






active

oldest

votes


















0














I think you are referring to the SSRS lookup function. You can;t use this directly in a Report Code function (as far as I know).



However, what you probably want to do is just use the lookup function to get your translation from a dataset called 'DSTranslation'. If this is correct them simply set the expression of the textbox (or whatever) to the lookup function.



So your textbox expression would just be



=LOOKUP(Fields!Token.Value, Fields!Token.Value, Fields!Translation.Value, "DS_Translation")


This assumes both datasets have a field called Token



If I've misunderstood then edit your question and explain what you are trying to do in a bit more detail and what data you have in your datasets.






share|improve this answer
























  • I understand that my goal it's not evident and modified my question. My starting expression to translate a textbox it's just what you wrote.

    – GLNebiacolombo
    Nov 28 '18 at 8:16













  • OK, I understand now. I'm 99% certain you can't do this. When I've faced a similar problem I've either setup the report as you have now or I've done all the translation in the dataset query.

    – Alan Schofield
    Nov 28 '18 at 9:46



















0














Its not possible to call Lookup() function in the custom code.






share|improve this answer































    0














    I found an answer to the goal of complexity reduction in the translation.
    This not resolve the question but it's a workaround for minimize the work on multilingual report preparation.
    You can use report variable as intermediate expression for the element to translate. If you define a variable for any element to translate like this:



    V_Hello=LOOKUP("Rpt_0_Hello", Fields!Token.Value, Fields!Translation.Value, "DS_Translation")


    You now can use the following expression on textbox:



    =Variables!V_Hello.Value


    It's not direct and short like the solution of the question, but if you respect naming you can automate the insertion of this variables into the report XML file .rpt (this is a future problem).

    With this you kill two birds with one stone because you simplify expression and evaluate the expression once. This may be useful on complex report.






    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53499100%2fssrs-access-built-in-functions-from-report-vb-code%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      I think you are referring to the SSRS lookup function. You can;t use this directly in a Report Code function (as far as I know).



      However, what you probably want to do is just use the lookup function to get your translation from a dataset called 'DSTranslation'. If this is correct them simply set the expression of the textbox (or whatever) to the lookup function.



      So your textbox expression would just be



      =LOOKUP(Fields!Token.Value, Fields!Token.Value, Fields!Translation.Value, "DS_Translation")


      This assumes both datasets have a field called Token



      If I've misunderstood then edit your question and explain what you are trying to do in a bit more detail and what data you have in your datasets.






      share|improve this answer
























      • I understand that my goal it's not evident and modified my question. My starting expression to translate a textbox it's just what you wrote.

        – GLNebiacolombo
        Nov 28 '18 at 8:16













      • OK, I understand now. I'm 99% certain you can't do this. When I've faced a similar problem I've either setup the report as you have now or I've done all the translation in the dataset query.

        – Alan Schofield
        Nov 28 '18 at 9:46
















      0














      I think you are referring to the SSRS lookup function. You can;t use this directly in a Report Code function (as far as I know).



      However, what you probably want to do is just use the lookup function to get your translation from a dataset called 'DSTranslation'. If this is correct them simply set the expression of the textbox (or whatever) to the lookup function.



      So your textbox expression would just be



      =LOOKUP(Fields!Token.Value, Fields!Token.Value, Fields!Translation.Value, "DS_Translation")


      This assumes both datasets have a field called Token



      If I've misunderstood then edit your question and explain what you are trying to do in a bit more detail and what data you have in your datasets.






      share|improve this answer
























      • I understand that my goal it's not evident and modified my question. My starting expression to translate a textbox it's just what you wrote.

        – GLNebiacolombo
        Nov 28 '18 at 8:16













      • OK, I understand now. I'm 99% certain you can't do this. When I've faced a similar problem I've either setup the report as you have now or I've done all the translation in the dataset query.

        – Alan Schofield
        Nov 28 '18 at 9:46














      0












      0








      0







      I think you are referring to the SSRS lookup function. You can;t use this directly in a Report Code function (as far as I know).



      However, what you probably want to do is just use the lookup function to get your translation from a dataset called 'DSTranslation'. If this is correct them simply set the expression of the textbox (or whatever) to the lookup function.



      So your textbox expression would just be



      =LOOKUP(Fields!Token.Value, Fields!Token.Value, Fields!Translation.Value, "DS_Translation")


      This assumes both datasets have a field called Token



      If I've misunderstood then edit your question and explain what you are trying to do in a bit more detail and what data you have in your datasets.






      share|improve this answer













      I think you are referring to the SSRS lookup function. You can;t use this directly in a Report Code function (as far as I know).



      However, what you probably want to do is just use the lookup function to get your translation from a dataset called 'DSTranslation'. If this is correct them simply set the expression of the textbox (or whatever) to the lookup function.



      So your textbox expression would just be



      =LOOKUP(Fields!Token.Value, Fields!Token.Value, Fields!Translation.Value, "DS_Translation")


      This assumes both datasets have a field called Token



      If I've misunderstood then edit your question and explain what you are trying to do in a bit more detail and what data you have in your datasets.







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Nov 27 '18 at 23:40









      Alan SchofieldAlan Schofield

      6,29511020




      6,29511020













      • I understand that my goal it's not evident and modified my question. My starting expression to translate a textbox it's just what you wrote.

        – GLNebiacolombo
        Nov 28 '18 at 8:16













      • OK, I understand now. I'm 99% certain you can't do this. When I've faced a similar problem I've either setup the report as you have now or I've done all the translation in the dataset query.

        – Alan Schofield
        Nov 28 '18 at 9:46



















      • I understand that my goal it's not evident and modified my question. My starting expression to translate a textbox it's just what you wrote.

        – GLNebiacolombo
        Nov 28 '18 at 8:16













      • OK, I understand now. I'm 99% certain you can't do this. When I've faced a similar problem I've either setup the report as you have now or I've done all the translation in the dataset query.

        – Alan Schofield
        Nov 28 '18 at 9:46

















      I understand that my goal it's not evident and modified my question. My starting expression to translate a textbox it's just what you wrote.

      – GLNebiacolombo
      Nov 28 '18 at 8:16







      I understand that my goal it's not evident and modified my question. My starting expression to translate a textbox it's just what you wrote.

      – GLNebiacolombo
      Nov 28 '18 at 8:16















      OK, I understand now. I'm 99% certain you can't do this. When I've faced a similar problem I've either setup the report as you have now or I've done all the translation in the dataset query.

      – Alan Schofield
      Nov 28 '18 at 9:46





      OK, I understand now. I'm 99% certain you can't do this. When I've faced a similar problem I've either setup the report as you have now or I've done all the translation in the dataset query.

      – Alan Schofield
      Nov 28 '18 at 9:46













      0














      Its not possible to call Lookup() function in the custom code.






      share|improve this answer




























        0














        Its not possible to call Lookup() function in the custom code.






        share|improve this answer


























          0












          0








          0







          Its not possible to call Lookup() function in the custom code.






          share|improve this answer













          Its not possible to call Lookup() function in the custom code.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 28 '18 at 8:57









          StrawberryshrubStrawberryshrub

          1,4232416




          1,4232416























              0














              I found an answer to the goal of complexity reduction in the translation.
              This not resolve the question but it's a workaround for minimize the work on multilingual report preparation.
              You can use report variable as intermediate expression for the element to translate. If you define a variable for any element to translate like this:



              V_Hello=LOOKUP("Rpt_0_Hello", Fields!Token.Value, Fields!Translation.Value, "DS_Translation")


              You now can use the following expression on textbox:



              =Variables!V_Hello.Value


              It's not direct and short like the solution of the question, but if you respect naming you can automate the insertion of this variables into the report XML file .rpt (this is a future problem).

              With this you kill two birds with one stone because you simplify expression and evaluate the expression once. This may be useful on complex report.






              share|improve this answer




























                0














                I found an answer to the goal of complexity reduction in the translation.
                This not resolve the question but it's a workaround for minimize the work on multilingual report preparation.
                You can use report variable as intermediate expression for the element to translate. If you define a variable for any element to translate like this:



                V_Hello=LOOKUP("Rpt_0_Hello", Fields!Token.Value, Fields!Translation.Value, "DS_Translation")


                You now can use the following expression on textbox:



                =Variables!V_Hello.Value


                It's not direct and short like the solution of the question, but if you respect naming you can automate the insertion of this variables into the report XML file .rpt (this is a future problem).

                With this you kill two birds with one stone because you simplify expression and evaluate the expression once. This may be useful on complex report.






                share|improve this answer


























                  0












                  0








                  0







                  I found an answer to the goal of complexity reduction in the translation.
                  This not resolve the question but it's a workaround for minimize the work on multilingual report preparation.
                  You can use report variable as intermediate expression for the element to translate. If you define a variable for any element to translate like this:



                  V_Hello=LOOKUP("Rpt_0_Hello", Fields!Token.Value, Fields!Translation.Value, "DS_Translation")


                  You now can use the following expression on textbox:



                  =Variables!V_Hello.Value


                  It's not direct and short like the solution of the question, but if you respect naming you can automate the insertion of this variables into the report XML file .rpt (this is a future problem).

                  With this you kill two birds with one stone because you simplify expression and evaluate the expression once. This may be useful on complex report.






                  share|improve this answer













                  I found an answer to the goal of complexity reduction in the translation.
                  This not resolve the question but it's a workaround for minimize the work on multilingual report preparation.
                  You can use report variable as intermediate expression for the element to translate. If you define a variable for any element to translate like this:



                  V_Hello=LOOKUP("Rpt_0_Hello", Fields!Token.Value, Fields!Translation.Value, "DS_Translation")


                  You now can use the following expression on textbox:



                  =Variables!V_Hello.Value


                  It's not direct and short like the solution of the question, but if you respect naming you can automate the insertion of this variables into the report XML file .rpt (this is a future problem).

                  With this you kill two birds with one stone because you simplify expression and evaluate the expression once. This may be useful on complex report.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Dec 10 '18 at 0:07









                  GLNebiacolomboGLNebiacolombo

                  11




                  11






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53499100%2fssrs-access-built-in-functions-from-report-vb-code%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

                      Calculate evaluation metrics using cross_val_predict sklearn

                      Insert data from modal to MySQL (multiple modal on website)