Question : Reorder Schedule Record

I have a schedluing database I am creating for work and was wondering how I could auto re-order numbers when a schedule changes for an employee. For example I have a form that filters out all  the jobs for employee Bob to run in a sub form:

Emplyee             Job         Schedule #
Bob                  Job A             1
Bob                  Job B              2
Bob                  Job C             2
Bob                  Job D            3

Is there some code or away to automatically renumber Job C to 3 and D to 4 if the scheduler wants to move job b to 2 saying it was 8 before? The refresh of the page put job B at 2. I just need to add 1 to every thing below it. This is a small example, there might be 30 jobs to schedule and I don't want to have the planner change all the numbers in the list manually.

Answer : Reorder Schedule Record

change the command65 code to the attached.
it worked when i run it on my pc

in the long run: it is VERY important that you give ALL your controls Meaningful names (such as renaming command65 to something like cmdReorder or something like that)
you might be getting along fine for now, but consider trying to read your code and debug/upgrade it in a year or two from now - you're gonna waste hours at best trying to know which is what. and letting someone else debug it is next to impossible...

and while at it, although possible to use square brackets, it's so much easier to code (and read code) if you stick to naming conventions (like no spaces and no special characters), then the brackets arent needed
(consider the difference between "[schedule #]" and "ScheduleOrd" or "ScheduleNum")

tell me if you need more help
now that i have your mdb it'll be easier
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
Dim LastValue As Long
 
LastValue = Me![Production Schedule By JSP subform].Form![Schedule #]
With Production_Schedule_By_JSP_subform.Form.Recordset
    .MoveNext
    While Not .EOF
        LastValue = LastValue + 1
        .Edit
        ![Schedule #] = LastValue
        .Update
        .MoveNext
    Wend
End With
Random Solutions  
 
programming4us programming4us