473,386 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Report on Missing Records in a Sequence

Our database tracks batches which have a Batch Number (ID). I'd like to know if there is a way to report on or return ID(s) that are missing from the sequence. Sometimes a user forgets to enter a batch and it would be nice to see which number is missing. I realize we can't report on a record that isn't there. But I was wondering if there is code that will allow us to see a break in the sequence of batch numbers?
Thank you.
May 16 '14 #1
1 1061
Seth Schrock
2,965 Expert 2GB
Depending on how many records you are returning, this could get expensive in terms of computer resources and take awhile to complete since you would have to loop through each record.

Because of the time it could take, I think that it would be best to first test if a number is missing and then if there is, check which one.
Expand|Select|Wrap|Line Numbers
  1. Dim db As DAO.Database
  2. Dim rst As DAO.Recordset
  3. Dim strRst As String
  4. Dim c As Integer 'If number of records is over 32,767, then us Long
  5. Dim s As Long
  6. Dim e As Long
  7.  
  8.  
  9. strRst = "SELECT ... ORDER BY ID"
  10. Set db = CurrentDb
  11. Set rst = db.OpenRecordset(strRst, dbOpenDynaset)
  12.  
  13. With rst
  14.     .MoveLast
  15.     e = !ID
  16.     .MoveFirst
  17.     s = !ID
  18.  
  19.     If e <> (s + .RecordCount - 1) Then
  20.         For c = s to e
  21.             If c <> !ID Then Debug.Print c
  22.         Next c
  23.     End If
  24.  
  25.     .Close
  26. End With
  27.  
  28. Set db = Nothing
  29. Set rst = Nothing
May 16 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: mark | last post by:
How do I get all fields on one page of a report? I have a report that has a column for each day of the week and 6 records for each day. I need each weekday's records returned on only one detail...
3
by: John Duchowski | last post by:
I've got a fairly large Access file with 4899 records. The ID field runs sequentially but misses two rows: it skips 3727 and 3740. Consequently, the dbase indicates that I have 4901 rows where in...
3
by: Alec | last post by:
Hi All, I want to create a report listing all the people's birthdays that are in the current month, in other words, if I clicked to open the report today, it would show everyone who's birthday...
0
by: Chris | last post by:
I finally got my report to be recongized, that login issue is terrible. Using VS.NET 2003, created report inside of it. Now when I attempt to display the report is blank (missing data, though I can...
1
by: shalini0702 | last post by:
Hi, I have Missing Records when exporing a table from (msaccess) One database to another. Supppose My Db has 10 tables and expoting all the table from One database to another was correct. ...
2
by: Blake | last post by:
Hello, I have a database that keeps track of cameras by location using their serial numbers. I have a report that in the report footer I have the following: =Count() This counts all the...
9
by: MicMic | last post by:
I want to be able to count all records in a report that if the field is greater than 0 it will total it. Example: 5 records are on the report, two of the records in the field Past Due have a...
55
by: tulikapuri | last post by:
I am developing a DB for a lab and at the end of the day i need to generate reports and send by email to supervisors, i had seven different reports to begin with, which i have brought down to 3, by...
11
by: jennifersalcido | last post by:
Hello All, I am working with two tables that contain inventory data: 1) INVENTORY contains item_number, description, etc. This data is relatively straight-forward, one record per item_number....
6
by: raamay | last post by:
i recently formatted my pc where sql server 2000 was installed. I backed up my db and then restored it after formatting. But today i came to know that all the recent records are lost (may be because...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.