Results 1 to 11 of 11
  1. #1
    ChobeyGuddu is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2016
    Posts
    29

    Post Else if Statement not executing - first if and elseif codes works fine but its not working for 3rd e

    Hi I have a code under after_update Event,
    first if and elseif codes works fine but its not working for 3rd elseif statements...

    not sure what i am doing incorrect here... can someone pls help

    code is :

    Private Sub PlanCompleteDate_AfterUpdate()


    If Not IsNull(Me.LowLevelBlocker) Then
    MsgBox (" Low Level Blocker needs to be removed to claim Plancompletedate")
    Me.PlanCompleteDate = ""

    ElseIf IsNull(Me.workorder) And Left(Me.Solution, 2) = "AB" Then
    MsgBox (" Pls enter workorder to claim Plancompletedate")
    Me.PlanCompleteDate = ""


    ElseIf Left(Me.Solution, 2) = "CD" Then


    If (IsNull(Me.LINKWO) Or IsNull(Me.LINK)) Then
    MsgBox ("Pls enter LINKWO & LINK to claim Plancompletedate")
    Me.PlanCompleteDate = ""
    End If


    End If


    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Are you sure it's the ElseIf and not the following If? Either set a breakpoint and step through the code or put a message box between those two lines to test.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Checking for null doesn't always work, some fields require the use of "" (double quotes) for empty

  4. #4
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,471
    I agree with pbaldy, best way to figure these things out is to put break point then F8 step through each line, checking the values (mouse over the fields) to see if they are what you are expecting.

    Are you sure there is a "CD" as left(2) in me.source in one of the records or else it won't go into that next If.

  5. #5
    ChobeyGuddu is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2016
    Posts
    29

    Post

    HI pbaldy
    Yes, its working uptill breakpoint...
    see the image...

    Click image for larger version. 

Name:	Breakpoint works.PNG 
Views:	19 
Size:	2.7 KB 
ID:	26086
    Quote Originally Posted by pbaldy View Post
    Are you sure it's the ElseIf and not the following If? Either set a breakpoint and step through the code or put a message box between those two lines to test.

  6. #6
    ChobeyGuddu is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2016
    Posts
    29
    Yes, there are 2 different values in me.Solution - AB and CD - so not sure what is going wrong here...

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Can you attach the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You might try this test:

    If Len(Me.LINKWO & vbNullString) = 0 Or Len(Me.LINK & vbNullString) = 0 Then
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    ChobeyGuddu is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2016
    Posts
    29
    Quote Originally Posted by aytee111 View Post
    Checking for null doesn't always work, some fields require the use of "" (double quotes) for empty

    Thanks aytee111,
    Replacing null with "" (Double quotes) worked fine...

    Thank you all for your time and efforts to help me getting there...

    Cheers
    Guddu.

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    FYI, the test in post 8 will check for both Null and a zero length string (""). I'd use it or something like it (Nz(), etc) that checks for both.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    ChobeyGuddu is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2016
    Posts
    29

    Post

    Quote Originally Posted by pbaldy View Post
    FYI, the test in post 8 will check for both Null and a zero length string (""). I'd use it or something like it (Nz(), etc) that checks for both.
    Thanks pbaldy,
    I would give it a go now and let you know..

    Cheers
    Guddu.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 12-15-2015, 04:01 PM
  2. Automate data input with If, Elseif Statement
    By Exmark1 in forum Programming
    Replies: 4
    Last Post: 02-19-2015, 09:52 AM
  3. Replies: 1
    Last Post: 11-14-2014, 05:12 PM
  4. Replies: 6
    Last Post: 10-15-2014, 02:45 PM
  5. If ElseIf Not Working
    By theperson in forum Programming
    Replies: 5
    Last Post: 02-27-2013, 07:40 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums