How do I reference a particular row in a report's dataset.

Posted on 2010-09-21
Last Modified: 2013-11-26
I'm looking for a way to display first and last entries in a report header, similar to a name range for a directory. list expressions that would allow this, but it only offers the absolute first and absolute last entries.  I'm trying to display the range for each page. (Ex: P1 A - E, P2 E - G, P3 H - MI, etc.)

I am using VB.NET through VS 2010 and an rdlc local report (not Crystal Reports).  I've tried referencing a function through the report object's expression, but got an 'not declared' error.  I've tried adding custom code to the report, as per  I can't manage to find a way to reference a specific row in the dataset from the report. (OpenForms(formname), frmFormName.DataTable, Dataset.Item() all give me the same 'not declared' error.)

Is there a way to generate the string I'm attempting either automatically or manually?  (If only manually, I can determine which records to use based on the page number.)
Question by:icegator2
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
LVL 101

Expert Comment

ID: 33726953
I dont know the RDLC product.

In Crystal I would do this with formulas int he page header and footer.
The page header formula would save the value you need from the first record on the page.
The page footer formula wuld do the same for the record it has and then display the value you want.


Expert Comment

ID: 33727118
So you have a column that has something like A-Z in the rows and you are breaking this master datatable into sub tables or lists on different pages such as you listed (P1 A - E, P2 E - G, P3 H - MI)?
Have you tried to create your needed strings and pass them to your report as parameters?  For some of these specific needs, I ususally pass parameters because it is easier to generate the result in code rather than on the rdlc report.

Author Comment

ID: 33727686
mlmcc:  There are 'First' and 'Last' expressions, but they are not page specific.  I can't access the dataset from the header or footer without using from a pre-defined set of expressions, so (Fields!Item.Value, 'Dataset') causes a build error instead of producing whatever happens to be the current dataset row. (i.e. first for page one and first for page twelve will be the same regardless of what actually prints on the page.)

puffdaddy411: I'm not breaking a master table into sub-tables.  Imagine if you printed a dictionary as a single report.  The entries are a continuous list, but at the top of each page, the entry range changes based on the page.
   Previously, I printed an odd page layout as a single report, followed by an even page layout as a single report, and so on.  The parameter 'NameRange' worked then, but it didn't allow me to duplex print the report.  I have since figured out how to control the layout for each page style in a single report.  Unfortunately, the parameter is no longer correct.  I tried to re-assign the parameter during 'QueryPageSettings', but I don't have access to the page number of the report.
   I toyed with the idea of using several 'NameRange' parameters, passing all the values to the report and controlling visibility via page number.  While I control records per page, I have no way of anticipating total pages, thus knowing how many parameters to put on the report.  This would probably mean adding an unrealistically large number of parameters and hoping the users never try to print more pages that that.
Raise the IQ of Your IT Alerts

From IT major incidents to manufacturing line slowdowns, every business process generates insights that need to reach the people required to take action. You need a platform that integrates with your business tools to create fully enabled DevOps toolchains.

You need xMatters.


Expert Comment

ID: 33728623
Sorry for the confusion here but I'm trying to get the details.  I got your dictionary example.  What type of object(s) are you placing on your report to display this information from your dataset?

Author Comment

ID: 33728862
In the header, I'm using a textbox.  In the body, a table.

Accepted Solution

puffdaddy411 earned 500 total points
ID: 33729118
Ok I've found something and got it to work on a dummy report I just created.  If we were using the dictionary example, we would have the name of the "Object" to be defined in a column (or even simply the first letter of the item).  In this case we will use "Object" as the column name.  Its first value would be "Aardvark", right?  =D
Anyway, if our dictionary was in a table (default name of "table1") in the report body, use the following line to show the first item on the current page in your page header.

The same can be done for the last item.
The only problem I see is that I got an error when I tried to add references to two report items in the same textbox in the header.  That apparently is not allowed.  So you could do some formatting with 2-3 separate textboxes to get the result you want.  Make sense?
P1: Aardvark - Bat
P1: A - B

Author Comment

ID: 33729493
So close.  Those expressions work great.  For some reason, it works fine on page one, but on page two (last page in this case), it makes itself and almost everything else in the header (not all though) invisible.

Now that you've pointed me in the right direction, I'll keep tweaking this and see if I can fix it.

Thanks a lot.

Expert Comment

ID: 33730033
I'm not in front of my PC, but try to trim() it. It sounds like the textbox is auto sizing due to extra blanks or something.

Expert Comment

ID: 33735379
Did the Trim() work for you?  I tested my make-shift report and did not have the same issue even without the Trim().

Author Comment

ID: 33735968
I had "CanGrow = False", so the "Trim()" wasn't necessary.  A partial solution was that when designing, I put the start and end entry textboxes in a rectangle, fit the rectangle to the size of the two boxes, then used the location property to move the rectangle.  This relocated the rectangle, but left the textboxes where they were relative to the report, not the rectangle (a weird quirk, to say the least).  When the report printed, it pushed the other headings below the textboxes and off the header, making it look as if everything disappeared.

I finally got it.  I was also referencing an odd page item for the heading on even pages and getting errors.  I actually figured this out while putting code in here.

Where did you find the "ReportItem()" expression?  I've been having trouble finding good resources for working with local reports.

Expert Comment

ID: 33736715
To be honest, I found "ReportItems()" in a random thread about a completely different subject.  I then researched it on MSDN.
I started playing with it and came up with what you needed.  The only resource, other than EE =D , is
Good Luck!

Featured Post

Get Actionable Data from Your Monitoring Solution

Your communication platform is only as good as the relevance of the information you send. Ensure your alerts get to the right people every time with actionable responses. Create escalation rules that ensure everyone follows the process and nothing is left to chance.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question