Results 1 to 4 of 4
  1. #1
    Kylester is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Nov 2012
    Posts
    2

    Display only sequential query data?

    Hello, I am somewhat new to Access but I am getting my feet wet very fast in a new job. My employer utilizes numerous databases including MS Access. I have full admin rights to Access so that is where I am focusing my attention right now. With that mouthful out of the way, is there a command to compare the results of a query for sequential string data? Sample: 56 2045800247 LenRod 01/06/2012 57 2046658440 ElmRod 04/06/2012 74 5078854744 GreenRod 08/04/2012 I have patched together a query that uses a primary key and sub-keys to gather output. This is in a database of > 10K records. Right now the results that I listed would be displayed as partial output of the executed query. What I would like to do is to eliminate the record that begins with the '74' because it is not in sequence with the other two. There only need to be two or more sequential numbers for the results to matter in what I am trying to do but anything that strips away single entries would help a great deal. Any help would be appreciated. Thank you, Kylester

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    This requires evaluating data in other records of same table. Usually requires subqueries. Not easy, especially since you want to exclude record(s) that doesn't continue the sequence.

    Explore this about subqueries: http://allenbrowne.com/subquery-01.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Kylester is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Nov 2012
    Posts
    2
    I was hoping to avoid that through the use of a function that possibly does not exist: "For value Current, if value Next is not equal to null, if Current value equals value Next minus one, Display Current." This is not canon but it is the idea that I was hoping to find in an existing function available for use within Access queries. Oh, and lest I forget, thank you for getting back to me!

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    Try:

    Query1
    SELECT Field1, Field2, Field3, Field4, (SELECT TOP 1 Dupe.Field1 FROM Table1 AS Dupe WHERE Dupe.Field1<Table1.Field1 ORDER BY Dupe.Field1 DESC) AS LastVal, (SELECT TOP 1 Dupe.Field1 FROM Table1 AS Dupe WHERE Dupe.Field1>Table1.Field1 ORDER BY Dupe.Field1) AS NextVal
    FROM Table1;

    Query2
    SELECT Field1, Field2, Field3, Field4
    FROM Query1
    WHERE (([Field1]+1=[NextVal])) OR (([Field1]-1=[LastVal]));
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 8
    Last Post: 01-13-2012, 08:20 AM
  2. make query fields not display if null data
    By rivereridanus in forum Queries
    Replies: 1
    Last Post: 07-05-2011, 08:19 AM
  3. Replies: 2
    Last Post: 02-20-2010, 01:11 AM
  4. Passing data to sequential form fields
    By jeepfamilyva in forum Forms
    Replies: 0
    Last Post: 06-28-2009, 11:04 AM
  5. Replies: 6
    Last Post: 02-20-2009, 11:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums