title: Im having a run time Error type mismatch when i try to run sql
body: <p>here is my code</p>
  
  <pre><code>Option Explicit
  Dim niFlag As Integer
  
  Private Sub OpenDB(ByRef cnn As ADODB.Connection)
  
  cnn.ConnectionString = "Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, 
  *.xlsb)};DBQ=" &amp; _
  
  
  ActiveWorkbook.Path &amp; Application.PathSeparator &amp; ActiveWorkbook.name
  
  cnn.Open
  
  End Sub
  
  
  Private Sub cmdPopul_Click()
  
  Dim strSQL As String
  
  Dim cnn As ADODB.Connection
  
  Dim rs As ADODB.Recordset
  
  niFlag = 1
  
  strSQL = "Select Distinct [Group] From [Data$] Order by [Group]"
  
  Set cnn = New ADODB.Connection
  
  OpenDB cnn
  
  cmbCompany.Clear
  
  Set rs = New ADODB.Recordset
  
  rs.Open strSQL, cnn, adOpenKeySet, adLockOptimistic
  
  Set cnn = Nothing
  
  If rs.RecordCount &gt; 0 Then
  
  Do While Not rs.EOF
  
  
  **cmbCompany.AddItem rs.Fields(0)** 'the error is here
  
  
  rs.MoveNext
  
  Loop
  
  Else
  
  MsgBox "I was not able to find any unique Group.", vbCritical + vbOKOnly
  
  Set rs = Nothing
  
  Exit Sub
  
  End If
  
  End Sub
  </code></pre>
  
  <p>Thanks for helping</p>