RE: Priority Change Update all records

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Create a function with three variables,
after update of priority for one of your records call the function by passing:

1) KeyID for the record changed
2) The Previous Priority
3) The Current Priority

In A Sub Like:

Private Sub RunPriorityUpdate()
Call UpdatePriorities(1479036363, 1, 10)
End Sub


Then your function would look something like this:

Private Function UpdatePriorities( _
plngKeyID As Long, _
plngOldPri As Long, _
plnNewPri As Long)

Dim daoDbs As DAO.Database
Dim pstrSql As String
Dim pstrOpr1 As String
Dim pstrOpr2 As String
Dim pstrOpr3 As String

Set daoDbs = CodeDb

If plngOldPri > plnNewPri Then
pstrOpr1 = "+1 "
pstrOpr2 = "<="
pstrOpr3 = ">="
Else
pstrOpr1 = "-1 "
pstrOpr2 = ">="
pstrOpr3 = "<="
End If

pstrSql = _
"UPDATE Table1 " & _
"SET Table1.Priority = " & _
"[Table1]![Priority]" & pstrOpr1 & _
"WHERE (((Table1.KeyID)<>" & _
plngKeyID & ") " & _
"AND ((Table1.Priority)" & _
pstrOpr2 & plngOldPri & _
" And (Table1.Priority)" & _
pstrOpr3 & plnNewPri & "));"

daoDbs.Execute (pstrSql)

End Function

Take Care & God Bless ~ SPARKER ~


"DDBeards" wrote:

I have an intiger field "Priority". I would like to write a simple loop that
updates all records when one records "Priority" is changed. For example, if
I have a record that is currently listed as Priority 5 and I wish to change
it to Priority 2, I need all 2 to be come 3 and 4 to become 5 and 5 to become
2, and leave all other records left alone.

any ideas?


.



Relevant Pages

  • Re: manipulation and memory allocation
    ... There aren't definite rules about how to manage memory. ... The first priority is for the code to do what it is designed to do. ... So when designing the interface to a function, think, "what does this ... "what happens if I am passed a giant string?". ...
    (comp.lang.c)
  • Re: erb example from comp.lang.ruby fails
    ... :16: undefined local variable or method `priority' for ... that's just regular ERB code. ... string * string * string ... insight into that problem, I'd appreciate one more insight from you. ...
    (comp.lang.ruby)
  • Re: Number to fractional string intermittently wrong
    ... OK, two updates: ... I ran the tool suggested by Alten in both modes it has and it didn't find any memory faults. ... Increase the priority of the VI or change the execution system of the VI to be something other than Standard: ... http://forums.ni.com/attachments/ni/170/245912/1/Number to string bug.PNG ...
    (comp.lang.labview)
  • Somewhat complex group by query
    ... I have one table with these columns: RowID, Priority, Country, ... i need a procedure that returns which string is ...
    (microsoft.public.access.queries)