MS Access 2013 - Can I print missing sequence numbers on a report?

I have a simple table that has a field called nTagno.     The field is an inventory tag number.   I need to know if any of the nTagno numbers are missing.      For example, My tags are numbered 1000-1250 and the table is the records with tags 1101 through 1105.    I was trying to find a way to show that those tags are missing.  Either with a report or query.  The tag numbers are sequential but I just don't have a process for finding the missing tag numbers.    Any suggestions?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

There's a bunch of different ways.
You could create a new table, tblAllTags
Add to it nTagno with the sequential numbers 1000-1250.

You could then build a Find Unmatched Query to find those items in tblAllTags that aren't in your existing table.
Rey Obrero (Capricorn1)Commented:
create a table with a single field [TagNo] name it myTags, and fill the field with all the tag numbers.
next create a query with a left join to your table

select [TagNo]
From myTags left join Table X
on mytags.tagno=tablex.[tagNumberfield]
where tablex.[tagNumberfield] is null

that should give you all the tag numbers that are missing in tableX
Dale FyeOwner, Developing Solutions LLCCommented:
Generally, I use a special table (tbl_Numbers) with only a single field (lngNumber) and 10 records (the values 0-9) for this type of thing.  With this table, you can create a query that generates any sequence of numbers, starting at any value. So, to generate a table with 1000 values, ranging from 0 to 1000, you would create a query like:

SELECT Hundreds.lngNumber * 100 + Tens.lngNumber * 10 + Ones.lngNumber
FROM tbl_Numbers as Hundreds, tbl_Numbers as Tens, tbl_Numbers as Ones
ORDER BY Hundreds.lngNumber * 100 + Tens.lngNumber * 10 + Ones.lngNumber

Name this qry_Numbers.

Then, from this, you could create a query similar to the following, which gives you a list of numbers ranging from the minimum to the maximum of your tag numbers.

SELECT lngNumber + DMIN("nTagno", "yourTagNumberTable") as TagNo
FROM qry_Numbers
WHERE qry_Numbers.lngNumber + DMIN("nTagno", "yourTagNumberTable") <= DMAX("nTagno", "yourTagNumberTable")

And then, finally, convert the previous query to a subQuery and use a LeftJoin to identify the missing tag numbers, something like:

SELECT lngNumber + DMIN("nTagno", "yourTagNumberTable") as TagNo
FROM qry_Numbers
WHERE qry_Numbers.lngNumber + DMIN("nTagno", "yourTagNumberTable") <= DMAX("nTagno", "yourTagNumberTable")
) as sq
LEFT JOIN yourTagNumberTable ON sq.TagNo = yourTagNumberTable.nTagNo)
WHERE yourTagNumberTable.nTagNo IS NULL

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jeffrey CoachmanMIS LiasonCommented:
I don't know anything about your business rules, I would ask why the nTagno number must be sequential. (hence you need to see which are "Missing".)

So could you clearly define what "missing" means and why it is a problem?

For example, If I have Products, the primary key is an autonumber.
I might have Product 125 products, but due to mistakes in data entry, I may actually only have 115 actual Products.
Since these "missing" products never actually existed (the data entry was aborted) they are not really missing, ...thus, a report to list them, might be meaningless...

Here, I am am not talking about "Discontinued" or "Inactive" products.

A discontinued product will be designated by an "Inactive" yes/no field in the main table.
So I can list all Inactive Products by a simple query like this:
SELECT ProductID, ProductName, ProductPrice, ProductActiive
FROM tblProducts
WHERE ProductActive=False

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.