Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2007
    Posts
    4

    Unanswered: Help with If Statement

    I am new to the group so for starters, Hello everyone, and I will let you know I am not the very good at VBA and coding. I am trying to do an If statement, and to most of you it's probable easy, but I am having trouble. Here goes. I have the 1st part OK. Here is the 1st part-----

    Private Sub ModelLineHandOffActDate_AfterUpdate()
    If (ModelLineHandOffActDate) > (ModelLineHandOffSchDate) Then
    Me.ModelLineHandOffOnTime = "Late"
    Else
    Me.ModelLineHandOffOnTime = "On Time"
    End If
    End Sub

    Simple enough, but I wanted to add one more layer at the top. and that is the part that is not working. I want ModelLineHandOffOnTime field to be blank if ModelLineHandOffSchDate is blank, so I tried

    Private Sub ModelLineHandOffActDate_AfterUpdate()
    If (ModelLineHandOffSchDate) Is Null Then
    Me.ModelLineHandOffOnTime = " "
    ElseIf (ModelLineHandOffActDate) > (ModelLineHandOffSchDate) Then
    Me.ModelLineHandOffOnTime = "Late"
    Else
    Me.ModelLineHandOffOnTime = "On Time"
    End If
    End Sub

    It blow up. It did not like Is Null. Can anyone help me.

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Try

    If IsNull(ModelLineHandOffSchDate) Then
    Paul

  3. #3
    Join Date
    May 2005
    Posts
    1,191
    or perhaps even

    If Nz(ModelLineHandOffSchDate, "") = "" Then

    if you want to check for null OR zls
    Me.Geek = True

  4. #4
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    ... Or

    If ModelLineHandOffSchDate & "" = "" Then

    Which does the same as Nick's ....
    Back to Access ... ADO is not the way to go for speed ...

  5. #5
    Join Date
    Jun 2007
    Posts
    4

    Thanks for the help

    Paul's code worked. I just needed to put the IsNull in front instead of on the back side. Thanks for the help.

Posting Permissions

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