Assign Round Robin Number 1,3,4,or 6

C

Christaaay

I am attempting to update the code below to now include queue 6 but it
doesn't work. It still only assigns values 1, 3, or 4 consistently. It is
used to assign a list number to each database record so that a query can
assign it to someone's attention. Please help!!!

Private Function SetQueueRouting()
'-- Added 12/12/2004
'--Sets queue_key field to the queue that was not routed to the last two deals
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim temp As Integer
Dim MyQ As Integer

Set db = CurrentDb
'Opens recordset based on query 'qryGetLast2QueueRoutings' to get last 2
queue routings
Set rs = db.OpenRecordset("SELECT Queue_Key FROM qryGetLast2QueueRoutings")

'Reads and concatenates last 2 Q routings into temp variable
rs.MoveFirst
temp = rs!Queue_Key 'read first Q routing into variable
rs.MoveNext
temp = temp & rs!Queue_Key 'read second Q routing into same variable
rs.MoveNext
temp = temp & rs!Queue_Key 'added for addition of 4th queue in round robin
11/26/05

If Me.Input05 = "RT14" Then 'If new record is a "system error" request type
then route to Q2
MyQ = 2
Else 'else set variable to whatever Q was not used in the last 2 Q routings
Select Case temp
Case 13, 31
MyQ = 4
Case 14, 41
MyQ = 3
Case 34, 43
MyQ = 1
'added q6 w/ randomly picked numbers 11/26/05
Case 57, 75
MyQ = 6
Case 11
MyQ = 3
Case 33
MyQ = 4
Case 44
MyQ = 1
Case 55
MyQ = 6
'q6 added on 11/26/05
End Select
End If

'set the function value to the chosen Q
SetQueueRouting = MyQ

rs.Close
db.Close

Set rs = Nothing
Set db = Nothing

End Function
 
T

tina

well, if i was following this correctly, once you've looped through the
recordset, isn't the value of the "temp" variable set to *three* numbers
rather than two? if you're checking the last three queue assignments, then
would the following code change handle it?

replace this code segment

Else 'else set variable to whatever Q was not used in the last 2 Q routings
Select Case temp
Case 13, 31
MyQ = 4
Case 14, 41
MyQ = 3
Case 34, 43
MyQ = 1

with

'else set variable to whatever Q was not used in the last 3 Q routings
ElseIf InStr(1, temp, 1) = 0 Then
MyQ = 1
ElseIf InStr(1, temp, 3) = 0 Then
MyQ = 3
ElseIf InStr(1, temp, 4) = 0 Then
MyQ = 4
ElseIf InStr(1, temp, 6) = 0 Then
MyQ = 6
End If

the above code basically says "if the string doesn't include a 1, then
assign 1, elseif the string doesn't include a 3, then assign a 3, elseif the
string doesn't include a 4, then assign a 4, elseif the string doesn't
include a 6, then assign a 6."

note that i didn't understand these Case values at all, so i don't know how
to address them:

Case 57, 75
MyQ = 6
Case 55
MyQ = 6

hth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top