Hello Accessers,
I am trying to have the code perform these things but unable to do so. While the code would still work, it will not move to the next user with either no date or the earliest date.
Goal:
-Go through the query record by record according to the date/time field
-Find the record with no date or earliest date (in that order)
-change its date to today's date
Code:
Code:
Private Sub Command56_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 = CurrentDb
stNextUser = ""
Set RS = MyDB.OpenRecordset("select * from qryTEST")
lngRSCount = RS.RecordCount
If lngRSCount <> 0 Then
RS.MoveFirst
stNextUser = Trim(RS.Fields("Initials").Value)
RS.Edit
RS.Fields("LastAssignment").Value = Now()
RS.Update
RS.Close
MyDB.Close
DoCmd.GoToRecord , , acNewRec
For i = 0 To .ListCount
If .ItemData(i) = stNextUser Then
.Value = stNextUser
End If
Next i
End If
Else
Me.AMID.SetFocus
End If
End With
End Sub
Any help would be appreciated.