Report Properties -> CODE issue

I'm trying to add a code function that returns a text field that is associated to one of the report parameters but am having problems with syntax.

The function below works in VB or VBS w/o erroir but in the SQL report i get the following error message.

"[BC30807] 'Let' and 'Set' assignment statements are no longer supported."

Removing the set statements alone only casues other erorrs. I've tried googling for examples but can't seem to find any.

Anyone able to point me in the right direction


Answer this question

Report Properties -> CODE issue

  • UnkName

    Ok, there is a simple workaround. You can't reference fields but you can reference report items. So you can reference the value of a textbox that already contains the data you want to display in the header/footer or you can create a hidden textbox that contains the query you want and reference this from the header or footer.

    To reference a report item value you use this syntax =ReportItems("ReportItemName").Value. So if I had a textbox named AreaName in the report that used this data set

    SELECT Name FROM dbo.tblAreas WHERE (ID = '@area').

    I would be able to get access the same data from the header by having a textbox that used this expression =ReportItems("AreaName").Value.

    See this link:

    http://msdn2.microsoft.com/en-us/library/ms157274.aspx


  • ghostwrtrone

    If I understood correctly you want to access the value of a data source an have it visible in the header area. For that you can use an internal report parameter that pulls the value from the report dataset. To do that you go to Report Parameters, click Add to add a new parameter, you can then fill out the name, data type (you wont need to fill out the prompt because the parameter will be internal). You then select Internal and from the Available values section select From Query: available Datasets and value fields should show up once you click this option. You can select the value from your datasets and you should be able to access the value in the header and footer section.

    Hope this helps


  • armin99

    Is there a reason you are embedding your query in your code Why not just create a Reporting Services data set and then associate that to the textbox. You can use the parameter in your query when defining the data set. It would look like

    SELECT Name FROM dbo.tblAreas WHERE (ID = '@area').

    Let me know if I am way off what you are trying to accomplish.


  • i_van

    I can see how that would work but I'd need to but an invisible field on the report. I'd rather find out the correct syntax for accessing an ADODB record set.

    Has anyone out there done so successfully


  • ZenX

    Yes, fields cannot be used in page headers or footer, I guess I should have included that in the original post
  • Report Properties -> CODE issue