Filter report by date greater than inputbox value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • crazyhouse
    New Member
    • Aug 2008
    • 31

    Filter report by date greater than inputbox value

    I am trying to view a report that has records that are filtered by date. basically all of the records that are greater than whatever date is entered into an input box. I would actually like to know how to give a start and an end date, but i figured i might be able to master that once i get the first code down. Here is what i cam currently using. ncrdate is a field from my table.
    Code:
        Dim stDocName As String
        Dim mydate
        Dim myval As String
     
     myval = InputBox("Please enter the start date.")
     mydate = DateValue(myval)
     MsgBox (mydate) 'I was just using this to make sure that it was reported as an actual date
        
        stDocName = "rptNCRSpread"
        DoCmd.OpenReport stDocName, acPreview, , "ncrdate > myval"
    Any help is greatly appreciated. I hope this question isnt too silly.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32661

    #2
    You're pretty close.

    The string should be :
    Code:
    "[ncrdate]>" & Format(myval,"\#m/d/yyyy\#")
    PS. It's only THAT complicated because it's a date. See Literal DateTimes and Their Delimiters (#).

    Comment

    • crazyhouse
      New Member
      • Aug 2008
      • 31

      #3
      Thanks, worked like a charm

      Comment

      Working...