p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Access VBA (http://p2p.wrox.com/forumdisplay.php?f=80)
-   -   inconsistent data (http://p2p.wrox.com/showthread.php?t=50101)

stealthdevil November 9th, 2006 11:28 AM

inconsistent data
 
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).
Code:

'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


mmcdonal November 9th, 2006 04:21 PM

If you have the table sorted on that row ASC, then it will do this every time it is updated.


mmcdonal

stealthdevil November 10th, 2006 05:03 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.

Code:

DoCmd.RunSQL ("delete * from tbl_os_reverse")
DoCmd.OpenQuery "qry_append_reverse"

Code:

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;




All times are GMT -4. The time now is 04:04 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.