title: VBA If statement confusion
body: <p>The below code worked fine until I added the code for the <code>vbokcancel</code> bit... code below:</p>
  
  <pre><code>If Me.results.ListIndex = -1 Or Me.userfolder.ListIndex = -1 Or
  Me.choice.ListIndex = -1 Then           
  
  MsgBox "Please choose something to remove"
  
  Else
  
  If MsgBox("Are you sure you want to delete this user from this folder?", vbOKCancel) = vbOK Then
  
      If Me.choice.Value = "Folder" Then
  
          username = Me.results.Column(0)
          prfolder = Me.results.Column(3)
  
          strSQL = "DELETE tblRelationship.*, tblPra.praNo, tblFolder.folder FROM tblPra INNER JOIN (tblFolder INNER JOIN tblRelationship ON tblFolder.folderID = tblRelationship.folderID) ON tblPra.praID = tblRelationship.praID WHERE (((tblPra.praNo)='" &amp; username &amp; "') AND ((tblFolder.folder)='" &amp; prfolder &amp; "'));"
          CurrentDb.Execute strSQL
          Me.results.Requery
  
      ElseIf Me.choice.Value = "Username" Then
  
          prfolder = Me.results.Column(0)
  
          strSQL = "DELETE tblRelationship.*, tblFolder.folder FROM tblPra INNER JOIN (tblFolder INNER JOIN tblRelationship ON tblFolder.folderID = tblRelationship.folderID) ON tblPra.praID = tblRelationship.praID WHERE (((tblFolder.folder)='" &amp; prfolder &amp; "'));"
          CurrentDb.Execute strSQL
          Me.results.Requery
  
      End If
    End If
  End If
  </code></pre>
  
  <p>It will activate the <code>If MsgBox("Are you sure you want to delete this user from this folder?", vbOKCancel) = vbOK</code> section but if the "OK" button is clicked it skips straight to the <code>End If</code> and does not run the code within the IF statement. Now I thought what I did was perfectly "Legal" in coding, apparently not... any ideas what I've done to screw up?</p>
  
  <p>If you press "Cancel" it does what I already want it to do, which is close the message box and the user is back at the same screen.. so there's no need for an Else statement because it already does what I want it to do. </p>