IS NUll Date Field

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DAHMB
    New Member
    • Nov 2007
    • 147

    #1

    IS NUll Date Field

    How do I format the following to work properly?

    Code:
    Private Sub btnFilterOutstanding_Click()
    
    Dim stFilter As String
    
        If "#Tables![tblMilitaryLeave]![DatePaid] ISNull#" Then
        stFilter = "Tables[tblMilitaryLeave]![DatePaid]"
        End If
    
        'Set the Filter property
        Reports!rptMilitaryLeave.Filter = stFilter
        Reports!rptMilitaryLeave.FilterOn = True
    
    End Sub
    Thanks
    Dan
    Last edited by Stewart Ross; Feb 9 '09, 05:04 PM. Reason: Replaced code tags to show code correctly as per Beacon's reply
  • beacon
    Contributor
    • Aug 2007
    • 579

    #2
    I think you need to write it like the following:
    Code:
    Private Sub btnFilterOutstanding_Click()
    
    Dim stFilter As String
    
    If IsNull(Tables![tblMilitaryLeave]![DatePaid]) Then
    stFilter = "Tables[tblMilitaryLeave]![DatePaid]"
    End If
    
    'Set the Filter property
    Reports!rptMilitaryLeave.Filter = stFilter
    Reports!rptMilitaryLeave.FilterOn = True
    
    End Sub
    I haven't tested this out...that jumped out at me as a possibility though.

    * When you are trying to indicate a code block, put brackets [ ] around the word code and end it with brackets around /code.

    Comment

    • ChipR
      Recognized Expert Top Contributor
      • Jul 2008
      • 1289

      #3
      I think you want:
      stFilter = "DatePaid IS NULL"

      Comment

      • DAHMB
        New Member
        • Nov 2007
        • 147

        #4
        No niether of the above is correct, my problem is that it is a date field and the Is Null does not seem to work with it as formated. Is there a way to write it so that it works with a date field?

        Comment

        • ChipR
          Recognized Expert Top Contributor
          • Jul 2008
          • 1289

          #5
          If "#Tables![tblMilitaryLeav e]![DatePaid] ISNull#"

          This doesn't make any sense as you are referring to an entire column of records. What are you trying to compare?

          Comment

          • DAHMB
            New Member
            • Nov 2007
            • 147

            #6
            I have a form that adds filters to an open report. I want this one to show only records that have no value in the DatePaid field

            and I tried "#Tables![tblMilitaryLeav e]![DatePaid] ISNull#" and I got a data type mismatch error.

            Comment

            • ChipR
              Recognized Expert Top Contributor
              • Jul 2008
              • 1289

              #7
              So you don't need the If condition at all. Just set the filter as in post #3 and apply it.

              Comment

              • DAHMB
                New Member
                • Nov 2007
                • 147

                #8
                Thankyou That was it!!! ifeel dumb but I learned something, thanks again!

                Comment

                • NeoPa
                  Recognized Expert Moderator MVP
                  • Oct 2006
                  • 32669

                  #9
                  In case it helps Dan :
                  Tags are done as matching pairs where the opening one is surrounded by [...] and the closing one by [/...]. A set of buttons is available for ease of use in the Standard Editor (Not the Basic Editor). The one for the [ CODE ] tags has a hash (#) on it. You can choose which editor to use in your profile options (Look near the bottom of the page).

                  Comment

                  • DAHMB
                    New Member
                    • Nov 2007
                    • 147

                    #10
                    I don't understand what you mean here could you give me an example of my mistake?

                    Comment

                    • NeoPa
                      Recognized Expert Moderator MVP
                      • Oct 2006
                      • 32669

                      #11
                      I'm not sure Dan. The original was changed by Stewart days ago now, & I haven't kept the email notification. If memory serves correctly though, you were using <> instead of []. EG :
                      <code>
                      Your code here
                      </code>
                      As it might be if it were HTML (This uses BBCode by the way).

                      Comment

                      • Stewart Ross
                        Recognized Expert Moderator Specialist
                        • Feb 2008
                        • 2545

                        #12
                        NeoPa's recollection matches mine, although I can't remember if it was angle brackets or none that had been used. You had actually marked the code segment clearly, either as

                        < CODE > ... < /CODE >

                        or simply

                        CODE ... /CODE

                        but in any event without using the brackets, so the delimiters didn't work.

                        -Stewart

                        Comment

                        Working...