Hi,
I ll try to find a way to find the missing number from range of numbers from a specific field and show this number with msgbox.
Any ideas?
Thanks in advance.
Here is an untested loop that gives another potential solution - Do while not rs.BOF and not rs.EOF //rs is a recordset ordered ASC by ID
-
thisID=rs!ID
-
rs.movenext
-
if thisID + 1<> rs!ID then
-
msgbox "Range Broken between " & thisID & " and " & rs!ID
-
endif
-
Loop
8 5395
not very clear but here is a sub that follows the gist of what I can get from your request -
-
Sub test()
-
complete_range = Array(1, 2, 3, 4, 5)
-
incomplete_range = Array(1, 2, 4, 5)
-
For Each num1 In complete_range
-
flag = False
-
For Each num2 In incomplete_range
-
If num2 = num1 Then
-
flag = True
-
End If
-
Next
-
If flag = False Then
-
MsgBox num1
-
End If
-
Next
-
-
End Sub
Thanks Pol for your reply.
My problem is that i have a field in table with name (id) and i want to see if the id field has sequence on it and if it has not to show in msgbox which number is missing from range...
OK, then you can still apply the same logic -
Sub sub1()
-
Dim rst As ADODB.Recordset
-
Call opendb
-
Set rst = objConn.Execute("SELECT id FROM Table1")
-
'where objConn is my Connection Object
-
-
For num = 1 To YourTableMaxID ' ... SELECT MAX(id) FROM YourTable
-
flag = False
-
Do While Not rst.EOF
-
dbID = rst(0)
-
If dbID = num Then
-
flag = True
-
End If
-
rst.MoveNext
-
Loop
-
If flag = False Then
-
MsgBox num
-
End If
-
rst.MoveFirst
-
Next
-
End Sub
zmbd 5,501
Expert Mod 4TB freedemi
Pod was kind enough to post a code for you; however, I would like to see the code with which you have already tried to solve the issue.
It could be something fairly simple in the logic. I know that when I did this in school, I over thought the solution (typical back then... forgot the "keep it simple..." rule). This was a favorite problem of the CompSci prof at university given to students... just because it is so easy to over think the solution.
I do have a code that will work on a simple table so if you will post your code (please remember to use the [code][/code] tags) I would be willing to compare the two.
thnx
-z
Here is an untested loop that gives another potential solution - Do while not rs.BOF and not rs.EOF //rs is a recordset ordered ASC by ID
-
thisID=rs!ID
-
rs.movenext
-
if thisID + 1<> rs!ID then
-
msgbox "Range Broken between " & thisID & " and " & rs!ID
-
endif
-
Loop
zmbd 5,501
Expert Mod 4TB
I'd still like to see what Freedemi has tried to solve the problem. As I said, this is a favorite problem given to comp-sci students by the profs at my university. The application for finding breaks in a contiguous series is very useful and something banks will do on statements etc... I have such a code in several of my databases that checks for serialized tamper seals on test containers... missing seal.... potential problems.
I have a nice little code that will give the report as asked for in OP. Once Freedemi's code is posted, I will gladly compare it with mine.
-z
Oh definitely zmbd. We all expect the OP to post his final solution or an explanation for future reference.
NeoPa 32,556
Expert Mod 16PB
Some of us (IE. the site) also expect the OP to provide their working/non-working code in the first post, along with a question that makes better sense.
Code relative to the OP's current understanding is so much more valuable than simple posted solutions - Hence the rules in place to encourage decent questions as well as responsive replies.
This question was borderline. If it hadn't already triggered so many responses I would have deleted it and let the OP post it again properly. Any members or experts can bring such questions to the attention of the mods by reporting them.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: nospam |
last post by:
Hi,
I have an application whose textareas rows automatically resize onFocus
to the number of lines in the textArea.
The cols are set to 100% (in a CSS file) in order to always take the
full...
|
by: Fiaz Idris |
last post by:
I am an access newbie and I have the following question.
Say, There is a text box in a form for input a number range and
the user inputs the following.
TextBox: AA123453,57-59,500,505-507,556...
|
by: Randy |
last post by:
How do you do a find on a range of Dates in a Date field from the find
dialog box?
|
by: Mahesh BS |
last post by:
Hello,
I need to write a query to find out a set of missing number in a given
sequence.
Eg : a Column in some table has the following data
|
by: le0 |
last post by:
Hello guys,
Im really having a hard time doing this, I have a record set with the ItemNo
field with the data type as Text. In the record that I have, I want to find
the missing number in the...
|
by: sharugan |
last post by:
Hi All,
I have requirement to find out the number of pages in a document.
The document could be DOC , TXT ,PDF images etc.I want to be able to upload and find out number of pages in an uploaded...
|
by: debasisdas |
last post by:
A ten-digit number contains every digit from 0 to 9. The digits are
arranged so that the number formed by the first two digits, reading from
left to right, is divisible by 2, the number formed by...
|
by: C C++ C++ |
last post by:
Hi all, got this interview question please respond.
How can you quickly find the number of elements stored in a a) static
array b) dynamic array ?
Rgrds
MA
|
by: fil66 |
last post by:
Hi There,
Is it possible to expand Hex number range?
Here is what I have in a text file...
002A:002F
03E0:03E0
03E2:03E2
07AF:07B1
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |