Re: Record Routing using MoveFirst and MoveNext
- From: "david epsom dot com dot au" <david@epsomdotcomdotau>
- Date: Mon, 28 Nov 2005 11:07:00 +1100
If n = 5 Then n = n + 1 'don't use queue 5 (mgr queue)
This takes it to queue 6
You probably should have put
if n = 5 then n = 1
Or, you can achieve the same affect by changing the mod
statement:
n = n Mod 4 'n = 0 to 3
n = n + 1 'n = 1 to 4
If n = 2 Then n = n + 1 'don't use queue 2 (system issues queue)
If 0 = InStr(temp, n) Then
You can write the first two lines as
n = minQue + (n mod (1 + maxQue- minQue))
However, you need to make sure that the code never
goes into an infinite loop. My code was wrong because
I assumed 5 active queues. You only have 3 active queues,
1,3,4, which means that to ensure that the loop breaks
you must only test the last 2:
temp = Left(temp, 2) 'only last 2 queues
otherwise it might loop for ever on
If 0 = instr("1341",n)
or you can break on a loop count.
Static n As Integer
for I = minQue to MaxQue
n = minQue + (n mod (1 + maxQue- minQue))
If n = 2 Then n = 3 'don't use queue 2 (system issues queue)
If n = 5 Then n = 1 'don't use queue 5 (mgr queue)
If (I=1) or (0 = InStr(temp, n)) Then myq = n
next I
"Christaaay" <Christaaay@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:2716E31C-914E-4AB5-B57A-F3E60A4B0B7C@xxxxxxxxxxxxxxxx
>I tried the second solution listed below which is routing records to the
> lists needed except for list 1. I also had to make a slight change as
> queue
> 5 is not included in the routing either, which also works fine. Any
> thoughts
> on why its skipping list 1? Here is the updated code I used.
>
> Static n As Integer
> Do
> temp = Left(temp, 4) 'only last 4 queues
> n = n Mod 5 'queues 0 to 4
> n = n + 1 'queues 1 to 5
> If n = 2 Then n = n + 1 'don't use queue 2 (system issues queue)
> If n = 5 Then n = n + 1 'don't use queue 5 (mgr queue)
> If 0 = InStr(temp, n) Then
> myq = n
> Exit Do
> End If
> Loop
>
>
> "david@epsomdotcomdotau" wrote:
>
>> 'here is a simple case statement:
>> Select Case True
>> case 0 = instr(Temp,1)
>> MyQ= 1
>> case 0 = instr(Temp,3)
>> MyQ= 3
>> case 0 = instr(Temp,4)
>> MyQ= 4
>> case 0 = instr(Temp,5)
>> MyQ= 5
>> End select
>>
>> 'here is the same thing as an if statement,
>> with a rotating entry point so that lower
>> numbers are not overloaded:
>> Static n As Integer
>> Do
>> temp = Left(temp, 4) 'only last 4 queues
>> n = n Mod 5 'queues 0 to 4
>> n = n + 1 'queues 1 to 5
>> If n = 2 Then n = n + 1 'don't use queue 2
>> If 0 = InStr(temp, n) Then
>> myq = n
>> Exit Do
>> End If
>> Loop
>>
>>
>> "Christaaay" <Christaaay@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> news:7A3CE530-EBE0-431C-8115-E060D69A17DC@xxxxxxxxxxxxxxxx
>> > I have been using the code below to distribute records in a round robin
>> > fashion to 3 different lists in access. I now need to add a fourth
>> > list
>> but
>> > cannot get the code to work. 'Queue' or 'Q' refers to the list that
>> > each
>> > record will be routed to. Can anyone 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
>> > routing
>> s
>> > 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
>>
>>
>>
.
- Follow-Ups:
- Re: Record Routing using MoveFirst and MoveNext
- From: Christaaay
- Re: Record Routing using MoveFirst and MoveNext
- References:
- Record Routing using MoveFirst and MoveNext
- From: Christaaay
- Re: Record Routing using MoveFirst and MoveNext
- From: david
- Re: Record Routing using MoveFirst and MoveNext
- From: Christaaay
- Record Routing using MoveFirst and MoveNext
- Prev by Date: 3021: no current record
- Next by Date: Re: Record Routing using MoveFirst and MoveNext
- Previous by thread: Re: Record Routing using MoveFirst and MoveNext
- Next by thread: Re: Record Routing using MoveFirst and MoveNext
- Index(es):
Relevant Pages
|