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
Solved

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

Posted on 2010-09-21
11
3,249 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
  • 6
  • 4
11 Comments
 
LVL 100

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
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 
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 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.
 

=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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to seperate number and letters from a string 3 22
MailAddress in vb 4 29
SSIS Feed MS SQL Server Stored procedure with loop 4 36
Easy filter aspnet 2 24
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

856 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