I have a userform called Attendance that has two listboxes on it. One called Seated, one called NotSeated.
In a SQL column everyone starts the day off as '1'. If someone is here today they get marked as '2', if they aren't they get marked as a '3' or a '4'.
I have a reset button that I want to have reset them to '1' when pressed. What I need to be able to do is to change my UPDATE query based on which listbox the user has currently highlighted. Here is what I have so far, but it's not working.
Sub resetagent()
database_connect
Dim AttendRecord As New ADODB.Recordset
Dim Cm As ADODB.Command
If appconn.State = 0 Then
Call database_connect
End If
Set Cm = New ADODB.Command
With Cm
.ActiveConnection = appconn
If attendance.Seated.value <> "" Then
.CommandText = "UPDATE [Attendance] SET [Seated] = '1' WHERE [Agentname]= '" & attendance.Seated.value & "'"
ElseIf attendance.NotSeated.value <> "" Then
.CommandText = "UPDATE [Attendance] SET [Seated] = '1' WHERE [Agentname]= '" & attendance.NotSeated.value & "'"
.CommandType = adCmdText
.Execute
End If
End With
Set AttendRecord = Nothing
database_Disconnect
End Sub
End Ifis in the wrong spot. Move it up 2 lines, just after the secondCommandText.