Hi,
I am working on writing a code to update records that has checkboxes checked.
================================================== ========================
Desired Scenario:
Assign a task to a manager with earliest assignment date who are 'Allowed to Auto Assign To'. (AllowAutoAssign checkbox field in the table)
For example:
Adam | AllowAutoAssign = True | Earliest Assignment = 5/1/00
BoB | AllowAutoAssign = False | Earliest Assignment = 2/1/00
Carl | Allow AutoAssign = True | Earliest Assignment = 3/1/00
I click on a button to assign a task and the code would run and update Carl's record.
================================================== ========================
I do not want to update BoB's even though he has the earliest assignment date because AllowAutoAssign is false.
How do I write a such code??? Here is the code I have below that works but will not check for those checkboxes.
Code:
Private Sub btnAssign_Click() Dim i As Long
With Screen.ActiveForm.[AMID]
Dim LResponse As Integer
LResponse = MsgBox("Do you wish to auto-assign to an Accreditation Manager?", vbYesNo, "Continue")
If LResponse = vbYes Then
Dim stNextUser As String
Dim MyDB As Object
Dim RS As Recordset
Set MyDB = DBEngine.Workspaces(0).Databases(0)
stNextUser = ""
Set RS = MyDB.OpenRecordset("select * from qryAIA_AutoAssignListWorkloadTrackingLog")
lngRSCount = RS.RecordCount
If lngRSCount <> 0 Then
With RS
.MoveFirst
stNextUser = Trim(RS.Fields("ID").Value)
.Edit
.Fields("LastAssignment").Value = Now()
.Update
.Close
End With
MyDB.Close
Else
MyDB.Close
End If
End If
DoCmd.GoToRecord , , acNewRec
For i = 0 To .ListCount
If .ItemData(i) = stNextUser Then
.Value = stNextUser
End If
Next i
Me.AMID.SetFocus
Me.AMID.Text = ""
Me.ACAID.SetFocus
frmSupport_AutoAssignWorkloadTrackingLog_Subform.Requery
MsgBox "Task assigned successfully."
Else
MsgBox "No task or manager to assign."
Me.AMID.SetFocus
End If
End With
End Sub