C
Christaaay
I am attempting to use the code below on a data access page to assign a
number to each record entered on the dap. the queries called specify the
numbers to use and the code is set up to make sure that only the specified
numbers are used and cycled through. Once all numbers have been used the
cycle should start over again. This is used to route records to 'work lists'
or 'queues' evenly to be worked. Any help you can give me would be great!
Function FetchQueueValue()
blnQueueNotInLastCycle = False
strCycledQueues = "SELECT * FROM tbl_AssocTbl " & _
"WHERE (((tbl_AssocTbl.cycled_ind)=True) AND
((tbl_AssocTbl.Queue) Is Not Null));"
strLastQueueCycleSequence = "SELECT * FROM qryGetQueueRoutingCycle"
Set rstQueuesToCycle = CreateObject("ADODB.Recordset")
Set rstLastQueueCycleSequence = CreateObject("ADODB.Recordset")
rstQueuesToCycle.Open strCycledQueues, MSODSC.Connection
rstLastQueueCycleSequence.Open strLastQueueCycleSequence, MSODSC.Connection
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.MoveFirst
rstLastQueueCycleSequence.Find "Queue_Key='" &
rstQueuesToCycle.Fields.item("queue").value & "'" 'check if a Queue was in
the last cycle
If rstLastQueueCycleSequence.EOF 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.Fields.item("queue").value
Else
rstLastQueueCycleSequence.MoveFirst 'or the queue at the beginning
of the last cycle
strReceivingQueue =
rstLastQueueCycleSequence.Fields.item("queue_key").value
End If
FetchQueueValue = strReceivingQueue
End If
rstLastQueueCycleSequence.Close
rstQueuesToCycle.Close
'Set rstQueueSequence = Nothing
Set rstQueuesToCycle = Nothing
End Function
number to each record entered on the dap. the queries called specify the
numbers to use and the code is set up to make sure that only the specified
numbers are used and cycled through. Once all numbers have been used the
cycle should start over again. This is used to route records to 'work lists'
or 'queues' evenly to be worked. Any help you can give me would be great!
Function FetchQueueValue()
blnQueueNotInLastCycle = False
strCycledQueues = "SELECT * FROM tbl_AssocTbl " & _
"WHERE (((tbl_AssocTbl.cycled_ind)=True) AND
((tbl_AssocTbl.Queue) Is Not Null));"
strLastQueueCycleSequence = "SELECT * FROM qryGetQueueRoutingCycle"
Set rstQueuesToCycle = CreateObject("ADODB.Recordset")
Set rstLastQueueCycleSequence = CreateObject("ADODB.Recordset")
rstQueuesToCycle.Open strCycledQueues, MSODSC.Connection
rstLastQueueCycleSequence.Open strLastQueueCycleSequence, MSODSC.Connection
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.MoveFirst
rstLastQueueCycleSequence.Find "Queue_Key='" &
rstQueuesToCycle.Fields.item("queue").value & "'" 'check if a Queue was in
the last cycle
If rstLastQueueCycleSequence.EOF 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.Fields.item("queue").value
Else
rstLastQueueCycleSequence.MoveFirst 'or the queue at the beginning
of the last cycle
strReceivingQueue =
rstLastQueueCycleSequence.Fields.item("queue_key").value
End If
FetchQueueValue = strReceivingQueue
End If
rstLastQueueCycleSequence.Close
rstQueuesToCycle.Close
'Set rstQueueSequence = Nothing
Set rstQueuesToCycle = Nothing
End Function