Accessers,
While trying to execute a code, I am getting an error:
Run-time error '438': "Object Doesn't Support This Property or Method"
I have looked around to find similar issue to the error I am getting on the code below:
Code:
Public Function AssignNextAM() Dim i As Long
With Screen.ActiveForm.[AMID]
Dim stNextUser As String
Dim MyDB As Database, RS As Recordset
Set MyDB = DBEngine.Workspaces(0).Databases(0)
stNextUser = ""
Set RS = MyDB.OpenRecordset("select * from qryAIA_WorkAgn")
lngRSCount = RS.RecordCount
If lngRSCount <> 0 Then
RS.MoveFirst
stNextUser = Trim(RS.Fields("Name").Value)
RS.Edit
RS.Fields("LastAgn").Value = Now()
RS.Update
RS.Close
MyDB.Close
MsgBox "This section works."
Else
RS.Close
stMsg = MsgBox("An error has occured: Please check if at least one person is allowed to be assigned.", vbCritical)
MyDB.Close
End If
DoCmd.GoToRecord , , acNewRec
For i = 0 To .ListCount <---Gets highlighted in Debugger
If .ItemData(i) = stNextUser Then
.Value = stNextUser
MsgBox "Person: " & stNextUser & " has been assigned to this activity and the log is updated.", vbApplicationModal
End If
Next i
End With
End Function
How may we tweak this to make it function properly?
Thanks!