Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2010-09-21
11
Medium Priority
?
3,534 Views
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.  http://msdn.microsoft.com/en-us/library/ms251668%28VS.80%29.aspx 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 http://msdn.microsoft.com/en-us/library/ms252130%28v=VS.80%29.aspx.  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.)
0
Comment
Question by:icegator2
[X]
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
11 Comments
 
LVL 101

Expert Comment

by:mlmcc
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.

mlmcc
0
 
LVL 5

Expert Comment

by:puffdaddy411
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.
0
 

Author Comment

by:icegator2
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.
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
LVL 5

Expert Comment

by:puffdaddy411
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?
0
 

Author Comment

by:icegator2
ID: 33728862
In the header, I'm using a textbox.  In the body, a table.
0
 
LVL 5

Accepted Solution

by:
puffdaddy411 earned 2000 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.
 

=First(ReportItems("Object").Value)
 
The same can be done for the last item.
 
 =Last(ReportItems("Object").Value)
 
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
OR
P1: A - B
0
 

Author Comment

by:icegator2
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.
0
 
LVL 5

Expert Comment

by:puffdaddy411
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.
0
 
LVL 5

Expert Comment

by:puffdaddy411
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().
0
 

Author Comment

by:icegator2
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.
OddPgHead.jpg
EvenPgHead.jpg
0
 
LVL 5

Expert Comment

by:puffdaddy411
ID: 33736715
icegator2,
 
To be honest, I found "ReportItems()" in a random thread about a completely different subject.  I then researched it on MSDN.
 
http://msdn.microsoft.com/en-us/library/ms251716(VS.80).aspx
 
I started playing with it and came up with what you needed.  The only resource, other than EE =D , is www.gotreportviewer.com.
 
Good Luck!
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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 …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

604 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