Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 9th, 2006, 11:28 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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

 
Old November 9th, 2006, 04:21 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

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


mmcdonal
 
Old November 10th, 2006, 05:03 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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;






Similar Threads
Thread Thread Starter Forum Replies Last Post
Why are number of pages inconsistent? Audioicon BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 October 16th, 2008 09:02 PM
Inconsistent Margin-Left Behavior rsearing CSS Cascading Style Sheets 5 August 6th, 2007 12:35 PM
Extract part of field from inconsistent data Roly Reefer Access VBA 4 March 31st, 2005 09:25 AM
Inconsistent error when retrieving data from a db darkhalf Classic ASP Databases 2 March 14th, 2004 12:38 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.