G
Guest
I am attempting to use the code below to run a query that looks at a series
of numbers for work lists (1,3,4,6) and assigns them in a cycle. It checks
to see if any of the numbers were not used in the previous cycle to evenly
distribute records to a user to work. When i run this code through the form
it gives an error message stating 'too few variables. expected 1.' Any idea
where i'm going wrong here? Thanks!!!
Private Function SetQueueRouting()
Dim db As DAO.Database
Dim rstQueuesToCycle As DAO.Recordset
Dim rstLastQueueCycleSequence As DAO.Recordset
Dim strCycledQueues As String
Dim strReceivingQueue As String
Dim blnQueueNotInLastCycle As Boolean
blnQueueNotInLastCycle = False
strCycledQueues = "SELECT * FROM tbl_Queue2Associate " & _
"WHERE (((tbl_Queue2Associate.cycled_ind)=True) AND
((tbl_Queue2Associate.Queue) Is Not Null));"
Set db = CurrentDb
Set rstQueuesToCycle = db.OpenRecordset(strCycledQueues, dbOpenSnapshot)
Set rstLastQueueCycleSequence = db.OpenRecordset("qryGetQueueRoutingCycle",
dbOpenSnapshot)
rstQueuesToCycle.MoveLast
If rstQueuesToCycle.RecordCount <> 0 Then 'if records exist
rstQueuesToCycle.MoveFirst 'go to first record
Do Until rstQueuesToCycle.EOF Or blnQueueNotInLastCycle = True 'loop
through cycled Queues
rstLastQueueCycleSequence.FindFirst "Queue_Key='" &
rstQueuesToCycle!queue & "'" 'check if a Queue was in the last cycle
If rstLastQueueCycleSequence.NoMatch Then 'if queue was not in last
cycle
blnQueueNotInLastCycle = True 'then set indicator to true and
exit the loop
Exit Do
End If
rstQueuesToCycle.MoveNext 'if queue was in last cycle then check the
next queue
Loop
If blnQueueNotInLastCycle = True Then 'sets the routing to either the
queue not already in the cycle
strReceivingQueue = rstQueuesToCycle!queue
Else
rstLastQueueCycleSequence.MoveFirst 'or the queue at the beginning
of the last cycle
strReceivingQueue = Nz(rstLastQueueCycleSequence!Queue_Key, "null")
End If
SetQueueRouting = strReceivingQueue
End If
'On Error Resume Next
rstLastQueueCycleSequence.Close
rstQueuesToCycle.Close
db.Close
'Set rstQueueSequence = Nothing
Set rstQueuesToCycle = Nothing
Set db = Nothing
End Function
of numbers for work lists (1,3,4,6) and assigns them in a cycle. It checks
to see if any of the numbers were not used in the previous cycle to evenly
distribute records to a user to work. When i run this code through the form
it gives an error message stating 'too few variables. expected 1.' Any idea
where i'm going wrong here? Thanks!!!
Private Function SetQueueRouting()
Dim db As DAO.Database
Dim rstQueuesToCycle As DAO.Recordset
Dim rstLastQueueCycleSequence As DAO.Recordset
Dim strCycledQueues As String
Dim strReceivingQueue As String
Dim blnQueueNotInLastCycle As Boolean
blnQueueNotInLastCycle = False
strCycledQueues = "SELECT * FROM tbl_Queue2Associate " & _
"WHERE (((tbl_Queue2Associate.cycled_ind)=True) AND
((tbl_Queue2Associate.Queue) Is Not Null));"
Set db = CurrentDb
Set rstQueuesToCycle = db.OpenRecordset(strCycledQueues, dbOpenSnapshot)
Set rstLastQueueCycleSequence = db.OpenRecordset("qryGetQueueRoutingCycle",
dbOpenSnapshot)
rstQueuesToCycle.MoveLast
If rstQueuesToCycle.RecordCount <> 0 Then 'if records exist
rstQueuesToCycle.MoveFirst 'go to first record
Do Until rstQueuesToCycle.EOF Or blnQueueNotInLastCycle = True 'loop
through cycled Queues
rstLastQueueCycleSequence.FindFirst "Queue_Key='" &
rstQueuesToCycle!queue & "'" 'check if a Queue was in the last cycle
If rstLastQueueCycleSequence.NoMatch Then 'if queue was not in last
cycle
blnQueueNotInLastCycle = True 'then set indicator to true and
exit the loop
Exit Do
End If
rstQueuesToCycle.MoveNext 'if queue was in last cycle then check the
next queue
Loop
If blnQueueNotInLastCycle = True Then 'sets the routing to either the
queue not already in the cycle
strReceivingQueue = rstQueuesToCycle!queue
Else
rstLastQueueCycleSequence.MoveFirst 'or the queue at the beginning
of the last cycle
strReceivingQueue = Nz(rstLastQueueCycleSequence!Queue_Key, "null")
End If
SetQueueRouting = strReceivingQueue
End If
'On Error Resume Next
rstLastQueueCycleSequence.Close
rstQueuesToCycle.Close
db.Close
'Set rstQueueSequence = Nothing
Set rstQueuesToCycle = Nothing
Set db = Nothing
End Function