G
Guest
I am attemping to build a two types of queies to resequence groups of records
in a DB. For example:
Records Now After update Query "A" After update
Query "B"
TSEQ DESC TSEQ DESC TSEQ
DESC
1 A 1 A
1 A
3 B 2 B
2 D
4 C 3 C
3 B
5 D 4 D
4 C
6 E 5 E
5 E
TSEQ is part of a unique key.
Query "A" is intended to remove any gaps in the sequence #
Query "B" is intended to run via an event in a form when the user changes
the TSEQ field.
I have started working on the query and have so far:
UPDATE [To Do List] SET [To Do List].Tseq = [tseq]+1
WHERE ((([To Do List].[To Do_CustomerID])="BAGTO") AND (([To Do List].[Proj
#])=1));
As you can see, I'm not even close, so here are my questons:
1. For "Query A" I assume I have to resequence from highest TSEQ to lowest
TSEQ so I don't duplicate a unique key. So how do I ORDER BY in Descending
order (the query design in MSAccess doesn't give me the option). Also, how
do I get the total # of records the query returned so I know what number to
decrement from?
2. For "Query B" I assume I need to 3 queries. One to give "D" a temporary
TSEQ, second to increment TSEQ for all records with a TSEQ >=2 by one, and a
third to give "D" the now available value of 2.
Being an access newbie, and a query neophite I am open to any and all
suggestions, or even a total change in approach. Actual SQL examples would
be mucho appreicated.
Bottom line is want to remove gaps be able to remove gaps from the sequence,
and want to be able to change the sequence.
Thanks..
in a DB. For example:
Records Now After update Query "A" After update
Query "B"
TSEQ DESC TSEQ DESC TSEQ
DESC
1 A 1 A
1 A
3 B 2 B
2 D
4 C 3 C
3 B
5 D 4 D
4 C
6 E 5 E
5 E
TSEQ is part of a unique key.
Query "A" is intended to remove any gaps in the sequence #
Query "B" is intended to run via an event in a form when the user changes
the TSEQ field.
I have started working on the query and have so far:
UPDATE [To Do List] SET [To Do List].Tseq = [tseq]+1
WHERE ((([To Do List].[To Do_CustomerID])="BAGTO") AND (([To Do List].[Proj
#])=1));
As you can see, I'm not even close, so here are my questons:
1. For "Query A" I assume I have to resequence from highest TSEQ to lowest
TSEQ so I don't duplicate a unique key. So how do I ORDER BY in Descending
order (the query design in MSAccess doesn't give me the option). Also, how
do I get the total # of records the query returned so I know what number to
decrement from?
2. For "Query B" I assume I need to 3 queries. One to give "D" a temporary
TSEQ, second to increment TSEQ for all records with a TSEQ >=2 by one, and a
third to give "D" the now available value of 2.
Being an access newbie, and a query neophite I am open to any and all
suggestions, or even a total change in approach. Actual SQL examples would
be mucho appreicated.
Bottom line is want to remove gaps be able to remove gaps from the sequence,
and want to be able to change the sequence.
Thanks..