Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Mar 2006
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    289
    Thanks
    0
    Thanked 1 Time in 1 Post

    Help with error message (2003 sp2)

    I cannot understand why I get the error message "invalid uses of Null" in this procedure at the first line beginning "IF Left(Me...". It worked fine when I first tested it and now it does not.

    The intention is to test for a 12/25 or 7/4 (any year) date and if true make a button on the form visible.

    Private Sub Combo17_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object
    Set rs = Me.Recordset.Clone
    rs.FindFirst "[ASSET_NUMBER] = '" & Me![Combo17] & "'"
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    If Left(Me.INSPECT_DATE, Len(Me.INSPECT_DATE) - 5) = "07/04" Then
    Me.cmd_ARC1.Visible = True
    End If
    If Left(Me.APPRAISE_DATE, Len(Me.APPRAISE_DATE) - 5) = "12/25" Then
    Me.cmd_ARC2.Visible = True
    End If
    End Sub
    Thanks
    chuck

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Help with error message (2003 sp2)

    If the control INSPECT_DATE is blank you'd get this error message, so you should check for that before the If statement, e.g.

    If IsNull(Me.INSPECT_DATE) Then
    MsgBox "Please enter a date!", vbExclamation
    Me.INSPECT_DATE.SetFocus
    Exit Sub
    End If

  3. #3
    3 Star Lounger
    Join Date
    Mar 2006
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    289
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Help with error message (2003 sp2)

    Why don't I think of these things? <img src=/S/bummer.gif border=0 alt=bummer width=15 height=15> However, null is valid for the Inspect_Date field if an inspection has never been done. I know, we never seem to give enough information.

    I changed the line to If Left(Me.INSPECT_DATE, 5) = "07/04" Then and I do not get any errors.

    I can't help wondering why it works when it essentially says the same thing.
    Thanks
    chuck

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Help with error message (2003 sp2)

    Left(Null, 5) returns Null, and Null doesn't equal "07/04", so that works as intended.

    Len(Null) is not 0 but Null, so Left(Null, Len(Null)-5) evaluates to Left(Null, Null) and VBA can't handle this.

  5. #5
    3 Star Lounger
    Join Date
    Mar 2006
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    289
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Help with error message (2003 sp2)

    Now I see said the blind man. <img src=/S/cool.gif border=0 alt=cool width=15 height=15>
    Thanks
    chuck

Posting Permissions

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