SSRS access built-in functions from report vb code
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
add a comment |
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
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 likeToken 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
add a comment |
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
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
sql-server vba reporting-services ssrs-2008-r2
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 likeToken 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
add a comment |
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 likeToken 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
add a comment |
3 Answers
3
active
oldest
votes
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.
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
add a comment |
Its not possible to call Lookup()
function in the custom code.
add a comment |
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.
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
Its not possible to call Lookup()
function in the custom code.
add a comment |
Its not possible to call Lookup()
function in the custom code.
add a comment |
Its not possible to call Lookup()
function in the custom code.
Its not possible to call Lookup()
function in the custom code.
answered Nov 28 '18 at 8:57
StrawberryshrubStrawberryshrub
1,4232416
1,4232416
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Dec 10 '18 at 0:07
GLNebiacolomboGLNebiacolombo
11
11
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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