title: End If in Access VBA giving me fits
body: <p>I keep getting an error in this code saying "End If without Block If".  I've looked at it and can't see the problem, printed it out and connected all the If statements to their joining End If, and everything looks right.  </p>
  
  <p>Is something else throwing e off, like that With/End With block?</p>
  
  <pre><code>Private Sub cmd__Import_Eligibility_Click()
  
  
     ' Requires reference to Microsoft Office 11.0 Object Library.
  
     Dim fDialog As FileDialog
     Dim varFile As Variant
     Dim filelen As Integer
     Dim filename As String
     Dim tblname As String
  
  
     ' Set up the File Dialog.
     Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
      fDialog.InitialFileName = "oo*.*"
     With fDialog
  
  
        ' Set the title of the dialog box.
        .Title = "Please select a file"
  
        ' Clear out the current filters, and add our own.
        .Filters.Clear
  
        .Filters.Add "Excel Spreadsheets", "*.xls*"
        .Filters.Add "Comma Separated", "*.CSV"
        .Filters.Add "All Files", "*.*"
  
        ' Show the dialog box. If the .Show method returns True, the
        ' user picked at least one file. If the .Show method returns
        ' False, the user clicked Cancel.
        If .Show = True Then
  
           'Loop through each file selected and add it to our list box.
           varFile = fDialog.SelectedItems(1)
           If Right(varFile, 4) = ".xls" Or Right(varFile, 5) = ".xlsx" Then
  
  
              'get only file name
              For a = Len(varFile) To 1 Step -1
                  If Mid(varFile, 1) = "\" Then
                      filelen = a
                  End If
              Exit For
              filename = Right(varFile, filelen)
              tblname = Left(filename, InStr(filename, ".") - 1)
              DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, tblname, filename, True
           End If 'ERRORS OUT ON THIS LINE ==========================
        Else
           MsgBox "You clicked Cancel in the file dialog box."
        End If
     End With
  
  End Sub
  </code></pre>