Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    Jan 2012
    Posts
    155
    Thanks
    118
    Thanked 0 Times in 0 Posts

    Problem: opening report fails to show data

    friends,

    I have a form with a textbox and a button that opens a report in accordance with the date placed in the text box. When I put the date 28/09/2012 the report opens with usually only records the date 28/09/2012.

    When I put the date 01/10/2012 shows no record in the report, but there are records to date.
    '------------------------------------------------------------------------------------------------
    Dim get_date As Variant
    get_date = txt_date

    DoCmd.OpenReport "report_log", acViewPreview, , "[Date_1]=#" & get_date & "#"
    '-----------------------------------------------------------------------------------------------
    I'm not able to decipher why this happens.

    All help is welcome.

    Thank you.

  2. #2
    Administrator
    Join Date
    Jun 2010
    Location
    Portugal
    Posts
    12,519
    Thanks
    152
    Thanked 1,398 Times in 1,221 Posts
    The report is based on a query, right? Have you tried running the query with that date value?

  3. The Following User Says Thank You to ruirib For This Useful Post:

    fabiobarreto10 (2012-10-01)

  4. #3
    2 Star Lounger
    Join Date
    Jan 2012
    Posts
    155
    Thanks
    118
    Thanked 0 Times in 0 Posts
    Hi Rui, thanks for offering help.

    Yes, the report is based on a query. I ran the query, putting the date 01/10/2012 with discretion. The query returns the record perfectly. When I open the report directly shows him the record with the date 01/10/2012. But when I open via the button on the form, placing the date in the text box, it shows no record in the report.

    I made a simple database, just to demonstrate my problem, but I'm having trouble sending the forum.

  5. #4
    2 Star Lounger
    Join Date
    Jan 2012
    Posts
    155
    Thanks
    118
    Thanked 0 Times in 0 Posts
    Rui,

    I created an email on gmail and attached the bank. the login is: report.problem.2012 and the password is: windowssecrets.
    The bank is in the inbox.

    Thanks for helping.

  6. #5
    Administrator
    Join Date
    Jun 2010
    Location
    Portugal
    Posts
    12,519
    Thanks
    152
    Thanked 1,398 Times in 1,221 Posts
    Try changing your code to this:

    Code:
    Dim get_date As Variant
    get_date = txt_date
    
    Debug.Print get_date
    
    DoCmd.OpenReport "report_log", acViewPreview, , "[Date_1]=#" & get_date & "#"
    Then put a breakpoint at the DoCmd.OpenReport line and check what value is output by the Debug.Print statement

  7. The Following User Says Thank You to ruirib For This Useful Post:

    fabiobarreto10 (2012-10-01)

  8. #6
    2 Star Lounger
    Join Date
    Jan 2012
    Posts
    155
    Thanks
    118
    Thanked 0 Times in 0 Posts
    Rui,

    I added the "Format" and now the value returned perfectly:

    DoCmd.OpenReport "report_log", acViewPreview, , "[Date_1]=#" & Format(get_date , "mm\/dd\/yyyy") & "#"



    Thanks for helping me again! :-)

  9. #7
    Administrator
    Join Date
    Jun 2010
    Location
    Portugal
    Posts
    12,519
    Thanks
    152
    Thanked 1,398 Times in 1,221 Posts
    Great . I was suspecting that the date format was incorrect and thus my suggestion to print it, to confirm that.

  10. The Following User Says Thank You to ruirib For This Useful Post:

    fabiobarreto10 (2012-10-01)

  11. #8
    2 Star Lounger
    Join Date
    Jan 2012
    Posts
    155
    Thanks
    118
    Thanked 0 Times in 0 Posts
    Perfect!

Posting Permissions

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