Results 1 to 2 of 2
  1. #1
    Join Date
    May 2014
    Posts
    98

    Unanswered: Else WITHOUT IF Compile error

    Private Sub WasIssueResolved_Click()
    On Error Resume Next
    If WasIssueResolved = True Then
    Forms!UnsafeAct!CloseDate.Visible = True
    CloseDate.Locked = True
    ' If IsNull(Me![ActionTakenBy PersonResponsible]) Then
    ' MsgBox "You must provide details of the Action Taken By Person Responsible.", vbOKOnly, "More Data Required!"
    ' Exit Sub
    End If

    Else
    Forms!UnsafeAct!CloseDate.Visible = False
    CloseDate.Locked = False
    End If

    End Sub

    I am compiling the database and I don't know why I am getting Else without If compile error

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    end if closes off the current if statement block
    code indentation helps diagnose these sort of errors, it also helps with code legibility

    Code:
    On Error Resume Next
    If WasIssueResolved = True Then
      Forms!UnsafeAct!CloseDate.Visible = True
      CloseDate.Locked = True
      '    If IsNull(Me![ActionTakenBy PersonResponsible]) Then
      '      MsgBox "You must provide details of the Action Taken By Person Responsible.", vbOKOnly, "More Data Required!"
      '      Exit Sub
    End If 'remove this endif
    
    Else 'If WasIssueResolved = True Then
      Forms!UnsafeAct!CloseDate.Visible = False
      CloseDate.Locked = False
    End If
    remember to turn the error handler back off after whatever code you are trying to protect against completes
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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