Author |
Topic |
Brutoxx
Starting Member
21 Posts |
Posted - 2005-04-05 : 10:59:06
|
I need to print on the header of my report a data which corresponds to the first day of the past month.Since this is not one of the globals and it seems that I can not use fields on the header is there any way to do this? |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-04-05 : 12:38:39
|
You can use VB.NET code to do this. Reporting Services allows you to use VB.NET functions. So take a look at the date functions in VB.NET.Tara |
 |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2005-04-05 : 13:01:37
|
I don't remember, but does RS have a DateAdd() function? Just write a formula that uses the global date and substracts 1 month from it. Either way, I'm sure RS has some built-in date manipulation formulas that you can use to get this. I do recall, as Tara mentioned, the help files not being to "helpful" when it comes to looking stuff like this up, though.- Jeff |
 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-04-05 : 13:03:40
|
RS has what VB.NET has. You can use any .NET language though, but you'd have to put them into an assembly and add those into each report. With VB.NET, you don't have to do this.Tara |
 |
|
Brutoxx
Starting Member
21 Posts |
Posted - 2005-04-05 : 13:05:07
|
Thank you.Now I understand I can't use a field at the header, but is there anyway to have a textbox in the header that equals a caption from a textbox on the body? That would fix my problem. |
 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-04-05 : 13:08:41
|
You can use a field in the header. ???Tara |
 |
|
Brutoxx
Starting Member
21 Posts |
Posted - 2005-04-05 : 13:11:07
|
d:\my documents\visual studio projects\totalbyagent\TotalByAgent.rdl The value expression for the textbox ‘textbox33’ refers to a field. Fields cannot be used in page headers or footers.This is the message I get! |
 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-04-05 : 13:14:23
|
Oh, page headers. I have used them in table headers. I don't use page headers or footers in my reports. So looks like you'll have to use the VB.NET functions to get this data in there.Tara |
 |
|
Brutoxx
Starting Member
21 Posts |
Posted - 2005-04-05 : 14:33:44
|
how can I find out about the VB.NET code? |
 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-04-05 : 14:37:02
|
If you've got a VB.NET book, see DateAdd and DatePart. You can also find examples of these on the Internet if you do some searching.Let's think about the logic. Today is April 5th. You'd want to display March in your report, right? So you'd get the current month from Now() (VB function to get current date and time). To get the month portion, use DatePart. So now we've got April. Use DateAdd to subtract one month from April. You've now got March. This should give you enough information to write the expression.Tara |
 |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2005-04-05 : 14:59:05
|
IN most report designers, you cannot put expressions that access the database in a page header or footer. the solution, though is easy in this case: Put the page header into a group header, and set group header to repeat at the top of all pages (thus becoming a page header). I often put a dummy group (grouping on , say, a constant value ) around the entire report, set that group's header to "repeat on all pages" and put any formula's for the report's page header into that group. Then you can remove the Page Header completely in most cases.- Jeff |
 |
|
Brutoxx
Starting Member
21 Posts |
Posted - 2005-04-05 : 15:40:08
|
I am sorry I am new Report Services, and the book I have is not the best.... How do I Put the page header into a group header? |
 |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2005-04-05 : 15:46:17
|
you don't put the page header into the group header, you set up a group and in the group header you edit the properties so that it will repeat at the top of each page. I forget the exact property name, you may have to poke around a little and experiment.EDIT: The property of the group header row in the table should have RepeatHeaderOnNewPage set to True.- Jeff |
 |
|
Brutoxx
Starting Member
21 Posts |
Posted - 2005-04-05 : 16:31:25
|
I am trying the first solutions, using vb. I have this code as my expression="Premium at: " & Format(Datepart(DateInterval.Month, Now)-1) & "/ " & Format(Datepart(DateInterval.Day, Now))&"/" &Format(Datepart(DateInterval.Year, Now))right now my result is 3/5/2005 I need to get the last day of the last month, so I need to modify the code above to return 3/21/2005.Thank you! |
 |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2005-04-05 : 16:45:34
|
To get the last day of the previous month, take the first day of the current month and substract 1 from it. Also, use the ToString() method to format things properly using VB.NET:="Premium at " & New Date(Year(Now), Month(Now), 1).AddDays(-1).ToString("MM/dd/yyyy")- Jeff |
 |
|
Brutoxx
Starting Member
21 Posts |
Posted - 2005-04-05 : 16:50:05
|
thank you very much, it worked great... |
 |
|
|