>What you have outlined would assign a new priority to the new records. Thank
>you!
[quoted text clipped - 3 lines]
>the new record a priority of 1. I would need the current records to be
>renumbered 2 to 11.
Marshall-
I'm Back. I tried this query again today and I noticed something that I
didn't notice before.
If I have list numbered from 1 to 5 and I want to reassign priority 5 to
number 2, the result that I am getting is the list is being numbered
1,2,4,5,6. If I run the query again, the result I get is 1,2,5,6,7. So I am
getting gaps in the numbering sequence. I have tried for loops and counter
variables but I am not getting the desired results.
Thanks!
> >What you have outlined would assign a new priority to the new records. Thank
> >you!
[quoted text clipped - 9 lines]
> Did you try it? If you did, what, exactly, was wrong with
> the result?
Marshall Barton - 13 May 2008 01:05 GMT
>I'm Back. I tried this query again today and I noticed something that I
>didn't notice before.
[quoted text clipped - 4 lines]
>getting gaps in the numbering sequence. I have tried for loops and counter
>variables but I am not getting the desired results.
That's what I meant when I asked if you would be reassigning
an existing priority. Here's an aircode version that will
do that too:
Dim db As Database
Dim SQL As String
Dim SetCond As String
Set db = CurrentDb()
If Not ((IsNull(Me.Priority.OldValue) _
And IsNull(Me.Priority)) _
Or (Me.Priority.OldValue = Me.Priority)) Then
If IsNull(Me.Priority.OldValue) Then
SetCond = "SET Priority = Priority + 1 " _
& "WHERE Priority >= " & Me.Priority
ElseIf IsNull(Me.Priority) Then
SetCond = "SET Priority = Priority - 1 " _
& "WHERE Priority > " & Me.Priority.OldValue
Else
If Me.Priority.OldValue < Me.Priority Then
SetCond = "SET Priority = Priority - 1 " _
& "WHERE Priority > " & Me.Priority.OldValue _
& " And Priority <= " & Me.Priority
ElseIf Me.Priority.OldValue > Me.Priority Then
SetCond = "SET Priority = Priority + 1 " _
& "WHERE Priority < " & Me.Priority.OldValue _
& " And Priority >= " & Me.Priority
End If
End If
SQL = "UPDATE [IS_Reporting Table] " _
& SetCond _
& " And Status <> 'resolved' And Status <> 'closed'"
db.Execute SQL
End If

Signature
Marsh
MVP [MS Access]
gst - 13 May 2008 16:33 GMT
Thanks. This works fine for the existing records.
Now I am getting duplicate priority numbers when a new record is added. I am
importing the new data data from a table. These new records are appended with
no assigned priority. A form is used to assign priorities to the new work
orders and this is where I am using the query that you have outlined below.
> >I'm Back. I tried this query again today and I noticed something that I
> >didn't notice before.
[quoted text clipped - 39 lines]
> db.Execute SQL
> End If