Results 1 to 3 of 3
  1. #1
    willmafingerdo is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2016
    Posts
    108

    Help with If...Then...ElseIf

    Hello,
    I am trying to update a date field based on a record code and I am having some issues. I am just learning the If command but my code looks like the examples im looking at but I don't know what is wrong.

    Private Sub DateOfRecentMedical_Click()
    If CaseStatusCode = "DE" Then
    MedicalFollowUpDate = DateAdd("m", 14, [DateOfRecentMedical])
    ElseIf
    CaseStatusCode = "PN" Then

    MedicalFollowUpDate = DateAdd("m", 36, [DateOfRecentMedical])
    ElseIf
    CaseStatusCode = "PR" Then



    MedicalFollowUpDate = DateAdd("m", 12, [DateOfRecentMedical])
    ElseIf
    CaseStatusCode = "PS" Then

    MedicalFollowUpDate = DateAdd("m", 14, [DateOfRecentMedical])
    ElseIf
    CaseStatusCode = "PW" Then

    MedicalFollowUpDate = DateAdd("m", 24, [DateOfRecentMedical])
    Else
    MedicalFollowUpDate = ""
    End If

    End Sub

  2. #2
    willmafingerdo is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2016
    Posts
    108
    I figured it out, I had to put the CaseStatusCode part on the ElseIf line and it works...

  3. #3
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Thanks for following up with the solution. FYI, you can combine the two that add 14 with OR:

    If Field = "A" Or Field = "B" Then
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. If Then / ElseIf Problem
    By ch5150 in forum Programming
    Replies: 4
    Last Post: 08-18-2015, 08:09 AM
  2. If then Elseif then....
    By Thompyt in forum Programming
    Replies: 3
    Last Post: 10-27-2014, 01:31 PM
  3. If ElseIf Not Working
    By theperson in forum Programming
    Replies: 5
    Last Post: 02-27-2013, 07:40 AM
  4. Help with ElseIf Statements
    By dshillington in forum Programming
    Replies: 6
    Last Post: 12-16-2011, 03:32 PM
  5. Easy one, If then ElseIf
    By Bruce in forum Forms
    Replies: 4
    Last Post: 12-01-2011, 12:44 PM

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