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:
Private Sub cmdAddOperator_Click() Dim strSQL As String Dim conn As ADODB.Connection Set conn = New ADODB.Connection Dim rs As ADODB.Recordset Set rs = New ADODB.Recordset conn.CursorLocation = adUseClient conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source =Database.mdb;" & _ "Persist Security Info=False" [b][color=red]rs.Open strSQL, conn, adOpenKeyset, adLockOptimistic[/color][/b][color=red][/color] strSQL = "SELECT Username " strSQL = strSQL & "FROM Users " strSQL = strSQL & "WHERE Username = '" & txtOperatorUsername.Text & "')" If txtOperatorUsername.Text = rs.Fields("Username").Value Then frmUsernameExists.Show ElseIf Val(txtOperatorPassword2.Text) <> Val(txtOperatorPassword.Text) Then frmOperatorPasswordNotSame.Show Else strSQL = "INSERT INTO Users " strSQL = strSQL & "(id,Username,Password,Operator,FullAccess) " strSQL = strSQL & "VALUES ('', " strSQL = strSQL & "'" & txtOperatorUsername.Text & "', " strSQL = strSQL & "'" & txtOperatorPassword.Text & "', " strSQL = strSQL & "'" & txtOperatorName.Text & "', " strSQL = strSQL & "'" & cboCompleteAccessYesNo.Text & "')" End If rs.Close Set rs = Nothing conn.Close Set conn = Nothing End Sub




Reply With Quote