Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 9th, 2006, 10:28 AM
Friend of Wrox
 
Join Date: May 2006
Location: Jonesboro, AR, USA.
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

Reply With Quote
  #2 (permalink)  
Old November 9th, 2006, 03:21 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
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
Reply With Quote
  #3 (permalink)  
Old November 10th, 2006, 04:03 PM
Friend of Wrox
 
Join Date: May 2006
Location: Jonesboro, AR, USA.
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;

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 08:25 AM
Inconsistent error when retrieving data from a db darkhalf Classic ASP Databases 2 March 14th, 2004 11:38 AM



All times are GMT -4. The time now is 06:08 AM.


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