|
Subject:
|
inconsistent data
|
|
Posted By:
|
stealthdevil
|
Post Date:
|
11/9/2006 10:28:33 AM
|
Hi, I'm having a problem with a module giving inconsistent data. It reads from the same sources every time I run it, but the data is not always the same. I have a couple of queries that run back to back inside the module. I think that one might be starting before the other finishes. There's also a loop that acts kind of strange(I think).
'Loop back through records to assign a sort order
Set rstflip = mydb.OpenRecordset("tbl_os_seq", DB_OPEN_TABLE)
rstflip.MoveFirst
While Not rstflip.EOF
row_cnt = row_cnt + 1
rstflip.Edit
rstflip![SORT KEY] = row_cnt
rstflip.Update
rstflip.MoveNext
Wend
When I step through this code I notice that when the first row is assigned a sort key it is then sent to the bottom of the table. The second row is then assigned a sort key and sent to the bottom of the table(below the first sort key). This continues thoughout the whole loop, so the first key does end up back at the top. This seems kind of odd to me. Is it normal for it to work this way?
Any thoughts? suggestions?
Thanks, Dave
|
|
Reply By:
|
mmcdonal
|
Reply Date:
|
11/9/2006 3:21:44 PM
|
If you have the table sorted on that row ASC, then it will do this every time it is updated.
mmcdonal
|
|
Reply By:
|
stealthdevil
|
Reply Date:
|
11/10/2006 4:03:05 PM
|
I think my problem may lie in this append query. The first query deletes all records from the reverse table. Then the second query copies all the records from the sequence tbl(that the module just created) into the reverse table. When this query runs it acts like it doesn't get all the way through the records. It should start with the last record from sequence table, but it doesn't always and I don't know why. There are 653 records in the table.
DoCmd.RunSQL ("delete * from tbl_os_reverse")
DoCmd.OpenQuery "qry_append_reverse"
INSERT INTO tbl_os_reverse ( LOGO, [YEAR], OCC, [NEW SEQ], OVERSIZED, CELLO, [PLAN QTY], [USAGE], [SIZE], [WHLSL PACK], [SALES DATE], [MARKETING NUMBER], [WHLSL AGIN], [WHLSL AGIN DESC], HOLIDAY, PLG, [PLG DESCRIPTION], [SORT KEY] )
SELECT tbl_os_seq.LOGO, tbl_os_seq.YEAR, tbl_os_seq.OCC, tbl_os_seq.[NEW SEQ], tbl_os_seq.OVERSIZED, tbl_os_seq.CELLO, tbl_os_seq.[PLAN QTY], tbl_os_seq.USAGE, tbl_os_seq.SIZE, tbl_os_seq.[WHLSL PACK], tbl_os_seq.[SALES DATE], tbl_os_seq.[MARKETING NUMBER], tbl_os_seq.[WHLSL AGIN], tbl_os_seq.[WHLSL AGIN DESC], tbl_os_seq.HOLIDAY, tbl_os_seq.PLG, tbl_os_seq.[PLG DESCRIPTION], tbl_os_seq.[SORT KEY]
FROM tbl_os_seq
ORDER BY tbl_os_seq.[SORT KEY] DESC;
|