PDA

View Full Version : Date Printing Problem in Access Reports



Urvi
10-26-2007, 08:38 AM
Hi Friends,

I don't know why it's not working!!!

I have a form from which I am accepting the begin and end dates.
I want a report between those dates.
So far so good. I have set the query criteria nad it is working and I am able to preview the report correctly with correect dates printed onscreen,

Now the trouble begins, When I try to print the report it prints the dates as 12/30/1999.


Can u help SOOOOOOOOOOOOOOON????

mattj
10-26-2007, 09:11 AM
In the controls on the report that display the date, what have you entered as the control source?

DarkSprout
10-26-2007, 02:00 PM
Hi Friends,...

Now the trouble begins, When I try to print the report it prints the dates as 12/30/1999.

Please provide some a code examples ~ I'm sure we can help.

Urvi
10-29-2007, 06:30 AM
I have two fields named,
BeginningDate and EndingDate on my form called ReportSelection

and then in my report in the report's pageheader i have a text field whose control source is set as follows,

="(Between " & Format([Forms]![ReportSelection]!BeginningDate,"m/d/yyyy") & " and " & Format([Forms]![ReportSelection]!endingdate,"m/d/yyyy") & ")"


AS i said the display onscreen shows ,
(Between 1/1/2007 and 10/28/2007)


but when i print the report i get,
(Between 12/31/1999 and 12/31/1999)

I hope this helps you understand my problem better.
Thanks for your help

DarkSprout
10-29-2007, 06:33 AM
Assuming that the path is correct, replace “m/d/yyyy” with “Short Date”.

mattj
10-29-2007, 06:36 AM
And ensure that the form remains open until the report is open.

Urvi
10-29-2007, 07:05 AM
the path is correct, i have tried replacing with shortdate and the form is open till the report is printed ....


same problem as yet
any other suggestions???

mattj
10-29-2007, 08:03 AM
Try:
="Between " & Format([Forms]![ReportSelection]!BeginningDate,"m/d/yyyy") & " and " & Format([Forms]![ReportSelection]!endingdate,"m/d/yyyy")

OTWarrior
10-29-2007, 08:13 AM
if BeginningDate and EndingDate the name of text boxes or dropdown fields then by my understanding it would be:

="Between " & Format([Forms]![ReportSelection]![BeginningDate],"m/d/yyyy") & " and " _
& Format([Forms]![ReportSelection]![endingdate],"m/d/yyyy")

otherwise, if it is a public varible that you pass over, it could be


="Between " & Format(BeginningDate(),"m/d/yyyy") & " and " & Format(endingdate(),"m/d/yyyy")

Urvi
10-29-2007, 08:27 AM
yes they are date picker controls on the form ..

OTWarrior
10-29-2007, 08:33 AM
have you tried putting a breakpoint on the code before the report fires, that way you can call the values in the debug window. so long as the information has been passed you could put the breakpoint anywhere

then you can find what the exact value are (or even if they are being found) in the immediate window
ie:
?([Forms]![ReportSelection]![BeginningDate])
?BeginningDate()


and if one of those work, you can then test the formatting

Urvi
10-29-2007, 09:29 AM
i am using
DoCmd.OpenReport stDocName, acViewPreview, , stRepCond

where stDocname is the name of the report, stRepcond is the filter /condition on the report. In this condition i am setting the dates as,


stRepCond = "[startdate] >= #" & Beginningdate & "# and [startdate] <= #" & endingdate & "#"

and then calling the docmd.openreport to preview/ print report?

where do i set the debug.

when i preview the report it shows correct dates onscreen but if i print then i get 12/30/1899


HELP !!!!!!!

OTWarrior
10-29-2007, 09:43 AM
So the dates are appearing correctly when you view the report, but not when you print to paper? or do you mean print to a file?

I do not follow how it can appear as one bit of data on screen, but different when you print it.

I did mention the debug is in the immediate window (Ctrl + G), and to set a breakpoint on a line of code, press F9 in the VB window. when you run the proceedure, it will stop on the breakpoint, and you are able to call any value that is loaded up until that point (such as startdate) by typing:

?startdate

which will show you it's value below itself.

Urvi
10-29-2007, 10:33 AM
i am outputing the data using
DoCmd.OpenReport stDocName, acViewPreview, , stRepCond

to preview the report

in the preview window u get an option to print also. If i click the print button i get the wrong dates although on screen it was showing OK. so i dont understand where to put the debug since i loose control after it opens the report.

am i making my problem clear?

OBP
10-29-2007, 12:06 PM
Urvi, have you tried putting the dates as Column Headers in your Query that supplies the Report's data. You can then pick up the Dates from there.

OTWarrior
10-30-2007, 01:36 AM
Urvi, you can get to the debug window if you put BREAKPOINTS on a line of code. If you are going to code in vba, you should learn how to debug and how to use the immediate window, it is a powerful tool.


i am outputing the data using
DoCmd.OpenReport stDocName, acViewPreview, , stRepCond


saying the same thing multiple times doesn't help, we understand what code you are using.

could you do a screenshot of what the report looks like normally, and do a mockup of the printed page?

XLGibbs
10-30-2007, 04:21 PM
when i preview the report it shows correct dates onscreen but if i print then i get 12/30/1899


HELP !!!!!!!

If the report is being sent to the printer without the procedure running first, it will be a null value or 0 producing that date. During testing to preview the report you are passing the parameters. Are you completely sure that the parameters are being passed to the print report command?

It seems to be you are setting them only for the ViewPreview and not the print.