Error:
Run-time error '-2147217908 (80040e0c)':
Command text was not set for the command object.

Highlighted line is the line debug points to.

What I am trying to do is first check the database table to see if the username value exists, if it does, throw up a form. If it doesnt exist, then to add the record to the database. I am sure thats the part that is at fault here.

Thanks in advance for any help.
VB Code:
  1. Private Sub cmdAddOperator_Click()
  2.     Dim strSQL As String
  3.    
  4.     Dim conn As ADODB.Connection
  5.     Set conn = New ADODB.Connection
  6.    
  7.     Dim rs As ADODB.Recordset
  8.     Set rs = New ADODB.Recordset
  9.    
  10.     conn.CursorLocation = adUseClient
  11.     conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  12.                "Data Source =Database.mdb;" & _
  13.                "Persist Security Info=False"
  14.    
  15.     [b][color=red]rs.Open strSQL, conn, adOpenKeyset, adLockOptimistic[/color][/b][color=red][/color]
  16.    
  17.     strSQL = "SELECT Username "
  18.     strSQL = strSQL & "FROM Users "
  19.     strSQL = strSQL & "WHERE Username = '" & txtOperatorUsername.Text & "')"
  20.  
  21.     If txtOperatorUsername.Text = rs.Fields("Username").Value Then
  22.         frmUsernameExists.Show
  23.    ElseIf Val(txtOperatorPassword2.Text) <> Val(txtOperatorPassword.Text) Then
  24.         frmOperatorPasswordNotSame.Show
  25.     Else
  26.         strSQL = "INSERT INTO Users "
  27.         strSQL = strSQL & "(id,Username,Password,Operator,FullAccess) "
  28.         strSQL = strSQL & "VALUES ('', "
  29.         strSQL = strSQL & "'" & txtOperatorUsername.Text & "', "
  30.         strSQL = strSQL & "'" & txtOperatorPassword.Text & "', "
  31.         strSQL = strSQL & "'" & txtOperatorName.Text & "', "
  32.         strSQL = strSQL & "'" & cboCompleteAccessYesNo.Text & "')"
  33.     End If
  34.  
  35.     rs.Close
  36.     Set rs = Nothing
  37.     conn.Close
  38.     Set conn = Nothing
  39. End Sub