Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Nov 2002
    Location
    Mt. Olive, North Carolina, USA
    Posts
    170
    Thanks
    8
    Thanked 0 Times in 0 Posts

    If statement (97)

    I have an IF statement that produces a object required error (run time error 424). I do not see what object I am missing.
    Private Sub EN_AfterUpdate()
    If Me.EN Is Not Null Then
    Me.FamNo = DLookup("[FamNo]", "[parishioner families list]", "EN =" & Me.[EN])
    Me.amount.SetFocus
    Else
    Me.FamNo.SetFocus
    End If
    End Sub
    Thank you in advance.
    John

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

    Re: If statement (97)

    Try changing

    If Me.EN Is Not Null Then

    to

    If Not IsNull(Me.EN) Then

  3. #3
    2 Star Lounger
    Join Date
    Nov 2002
    Location
    Mt. Olive, North Carolina, USA
    Posts
    170
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Re: If statement (97)

    Yes that worked. Thanks.

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

    Re: If statement (97)

    Explanation: "Is Null" and "Is Not Null" can be used in the criteria line in a query and in the WHERE clause of an SQL statement.
    In VBA, the keyword "Is" can only be used for object variables (and in Case statements, but that's a different subject). The equivalent of "Is Null" in VBA is the IsNull function, used in the form

    If IsNull(expression) Then

    or

    If Not IsNull(expression) Then

Posting Permissions

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