Consulting

Results 1 to 17 of 17

Thread: Date Printing Problem in Access Reports

  1. #1
    VBAX Regular
    Joined
    Oct 2007
    Posts
    20
    Location

    Date Printing Problem in Access Reports

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

  2. #2
    In the controls on the report that display the date, what have you entered as the control source?
    Matt Jones
    MS Access Certified Professional 2K/2003

  3. #3
    VBAX Contributor DarkSprout's Avatar
    Joined
    Oct 2007
    Location
    Essex, England
    Posts
    144
    Location
    Quote Originally Posted by Urvi
    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.
    =|)arkSprout=
    VBA | VBScript | C# Programmer

    "Give a person a fish and you feed them for a day; teach a person to use the Internet and they won't bother you for weeks."

  4. #4
    VBAX Regular
    Joined
    Oct 2007
    Posts
    20
    Location
    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

  5. #5
    VBAX Contributor DarkSprout's Avatar
    Joined
    Oct 2007
    Location
    Essex, England
    Posts
    144
    Location
    Assuming that the path is correct, replace “m/d/yyyy” with “Short Date”.
    =|)arkSprout=
    VBA | VBScript | C# Programmer

    "Give a person a fish and you feed them for a day; teach a person to use the Internet and they won't bother you for weeks."

  6. #6
    And ensure that the form remains open until the report is open.
    Matt Jones
    MS Access Certified Professional 2K/2003

  7. #7
    VBAX Regular
    Joined
    Oct 2007
    Posts
    20
    Location
    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???

  8. #8
    Try:
    ="Between " & Format([Forms]![ReportSelection]!BeginningDate,"m/d/yyyy") & " and " & Format([Forms]![ReportSelection]!endingdate,"m/d/yyyy")
    Matt Jones
    MS Access Certified Professional 2K/2003

  9. #9
    VBAX Mentor OTWarrior's Avatar
    Joined
    Aug 2007
    Location
    England
    Posts
    389
    Location
    if BeginningDate and EndingDate the name of text boxes or dropdown fields then by my understanding it would be:

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

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

    [vba]
    ="Between " & Format(BeginningDate(),"m/d/yyyy") & " and " & Format(endingdate(),"m/d/yyyy")
    [/vba]
    -Once my PC stopped working, so I kicked it......Then it started working again

  10. #10
    VBAX Regular
    Joined
    Oct 2007
    Posts
    20
    Location
    yes they are date picker controls on the form ..

  11. #11
    VBAX Mentor OTWarrior's Avatar
    Joined
    Aug 2007
    Location
    England
    Posts
    389
    Location
    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
    -Once my PC stopped working, so I kicked it......Then it started working again

  12. #12
    VBAX Regular
    Joined
    Oct 2007
    Posts
    20
    Location
    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 !!!!!!!

  13. #13
    VBAX Mentor OTWarrior's Avatar
    Joined
    Aug 2007
    Location
    England
    Posts
    389
    Location
    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.
    -Once my PC stopped working, so I kicked it......Then it started working again

  14. #14
    VBAX Regular
    Joined
    Oct 2007
    Posts
    20
    Location
    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?

  15. #15
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    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.

  16. #16
    VBAX Mentor OTWarrior's Avatar
    Joined
    Aug 2007
    Location
    England
    Posts
    389
    Location
    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?
    -Once my PC stopped working, so I kicked it......Then it started working again

  17. #17
    VBAX Master XLGibbs's Avatar
    Joined
    Jan 2006
    Location
    state of confusion, but vacation in denial
    Posts
    1,315
    Location
    Quote Originally Posted by Urvi

    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.
    If you have posted the same question at multiple forums, please read this IMPORTANT INFO.

    Please use the thread tools to mark your thread Solved


    Please review the Knowledge Base
    for samples and solutions , or to submit your own!




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •