Question : Arguments are of the wrong type SQL error

It appears that I am going to struggle to get every SQL statement I ever write to work 1st time!  At present I have the code below but seem to get a 3001 error - "Arguments are of the wrong type, are out of acceptable range or are in conflict with another".

txtUsername variable value is "simonwait"

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
Dim rsPubs As ADODB.Recordset
Set rsPubs = New ADODB.Recordset
Dim enPubs As ADODB.Connection
Set enPubs = New ADODB.Connection

If txtUsername = "" Then
MsgBox ("No user selected")
Exit Sub
End If
'Now open the connection.
enPubs.Open strConn
With rsPubs
    ' Assign the Connection object.
    .ActiveConnection = enPubs
    ' Update the required records.
.Update "Users SET Removed=1 WHERE Username='" & txtUsername & "'"
 .Close
End With

dnPubs.Close
Set rsPubs = Nothing
Set enPubs = Nothing

Answer : Arguments are of the wrong type SQL error

Here is the final code (tested and worked for me):
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
Dim rsPubs As ADODB.Recordset
Set rsPubs = New ADODB.Recordset
Dim enPubs As ADODB.Connection
Set enPubs = New ADODB.Connection

If txtUsername = "" Then
MsgBox ("No user selected")
Exit Sub
End If
'Now open the connection.
enPubs.Open strConn
With rsPubs
    ' Assign the Connection object.
    .ActiveConnection = enPubs
    .CursorType = adOpenKeyset
    .LockType = adLockOptimistic
    .CursorLocation = adUseServer
    .Open "select * from users WHERE Username='" & txtUsername & "'"
    ' Update the required records.
    If Not (.EOF Or .BOF) Then
        !Removed = 1
        .Update
    Else
        MsgBox "Username does not exist: " & txtUsername
    End If
    .Close
End With

enPubs.Close
Set rsPubs = Nothing
Set enPubs = Nothing
Random Solutions  
 
programming4us programming4us