473,406 Members | 2,549 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,406 software developers and data experts.

Select records in sequential chronologial order

maxamis4
295 Expert 100+
Hello folks,

I have two forms a parent form and a subform. The parent form is an unbound form while the subform is a form that contains all a list of what I like to call 'in stock ' phone numbers. with in that subform the user has the ability to select between to radio buttons to do a bulk selection. The first option lets the user select the first X amount of numbers that he or she wants. The second option selects X amount of numbers but they all must be in chronological order. If the numbers even skip a number it should return with a message no numbers avaiable in that order. Example
the txt box where a user enters the number of phone numbers he or she wants to select is called txt_LumpSelect

So a user enters 5 in text_Lumpselect and clicks on the grab button what it should select in the subform is the first 5 sequential numbers like so:
1234567
1234568
1234569
1234570
1234571


if it can not find any numbers that fit the required 5 in sequential order, an error message should be prompted that says no numbers in sequence.

Please note I don't need it to filter just to check the box check box that goes with the number. Filtering would just be an added bonous if someone can help with this process


How do I accomplish this feat
below is the selection process for the non sequential numbers which I quess whas the easier part. Any ideas,

Thanks
Code:
--------------------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. Private Sub btn_LumpGrap_Click()
  2. 'Sets the status of the TN to in service as well as sets the Service Value to -1 to make sure it is checked off
  3. mysql = "SELECT tbl_Phone_Arch.DID, tbl_Phone_Arch.Status, tbl_Phone_Arch.ServiceValue" _
  4. & " FROM tbl_Phone_Arch" _
  5. & " WHERE (((tbl_Phone_Arch.Status)='In Stock'))" _
  6. & " ORDER BY tbl_Phone_Arch.DID"
  7. Set db = CurrentDb()
  8. Set rs = db.OpenRecordset(mysql, dbOpenDynaset)
  9.  
  10.  
  11. If (Opt_Non) = -1 Then
  12.         If IsNull(txt_LumpSelect) Then
  13.             Exit Sub
  14.         Else
  15.         i = 0
  16.             Do While i < Val(txt_LumpSelect)
  17.                 rs.Edit
  18.                     rs!Status = "In Service"
  19.                     rs!ServiceValue = -1
  20.  
  21.                 rs.Update
  22.             rs.MoveNext
  23.             i = i + 1
  24.             Loop
  25.  
  26.         End If
  27. Else
  28.     If (Opt_Seq) = -1 Then
  29.  
  30.         Do While i < Val(txt_LumpSelect)
  31.  
  32.  
  33.  
  34.  
  35.             If rs.EOF Then
  36.                 MsgBox "Not enough numbers in sequence!"
  37.                 Exit Sub
  38.             Else
  39.                 rs.MoveNext
  40.             End If
  41.         Loop
  42.     Else
  43.      MsgBox "Please select an assignement Method"
  44.      Exit Sub
  45.     End If
  46.  
  47. End If
  48. Form.Refresh
  49.  
  50. End Sub
Apr 6 '07 #1
1 2437
MMcCarthy
14,534 Expert Mod 8TB
Try this ...
Expand|Select|Wrap|Line Numbers
  1. Private Sub btn_LumpGrap_Click()
  2. 'Sets the status of the TN to in service as well as sets the Service Value to -1 to make sure it is checked off
  3. mysql = "SELECT tbl_Phone_Arch.DID, tbl_Phone_Arch.Status, tbl_Phone_Arch.ServiceValue" _
  4. & " FROM tbl_Phone_Arch" _
  5. & " WHERE (((tbl_Phone_Arch.Status)='In Stock'))" _
  6. & " ORDER BY tbl_Phone_Arch.DID"
  7. Set db = CurrentDb()
  8. Set rs = db.OpenRecordset(mysql, dbOpenDynaset)
  9.  
  10. If (Opt_Non) = -1 Then
  11.         If IsNull(txt_LumpSelect) Then
  12.             Exit Sub
  13.         Else
  14.         i = 0
  15.             Do While i < Val(txt_LumpSelect)
  16.                 rs.Edit
  17.                     rs!Status = "In Service"
  18.                     rs!ServiceValue = -1
  19.  
  20.                 rs.Update
  21.             rs.MoveNext
  22.             i = i + 1
  23.             Loop
  24.  
  25.         End If
  26. ElseIf (Opt_Seq) = -1 Then
  27.  
  28. Dim tmpDID As Long
  29.  
  30. rs.MoveFirst
  31.         Do While i < Val(txt_LumpSelect)
  32.                 tmpDID = rs!DID
  33.     rs.MoveNext
  34.     If i < Val(txt_LumpSelect) Then
  35.        If rs!DID <> (tmpDID + 1)  Then
  36.           Msgbox "No sequence", vbOkOnly
  37.           Exit Sub
  38.        End If
  39.    End If
  40. Loop
  41.  
  42. rs.MoveFirst
  43. Do While i < Val(txt_LumpSelect)
  44.                 rs.Edit
  45.                     rs!Status = "In Service"
  46.                     rs!ServiceValue = -1
  47.  
  48.                 rs.Update
  49.             rs.MoveNext
  50.             i = i + 1
  51.             Loop
  52.  
  53. End If
  54. Form.Refresh
  55.  
  56. End Sub
Mary
Apr 11 '07 #2

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

Similar topics

4
by: Bryan Harrington | last post by:
Can you use Select top 40 * from ... and ORDER BY... in the same query? I have the following 4 quearies that are.. for the most part, the same except the order by clause, all return a differnt...
8
by: Adam Nemitoff | last post by:
Is is possible to construct a SELECT statement that contains a WHERE clause that uses the value from a column in the "next" row? ie. given a table with a single field named "myField" with the...
5
by: malcolm | last post by:
Example, suppose you have these 2 tables (NOTE: My example is totally different, but I'm simply trying to setup the a simpler version, so excuse the bad design; not the point here) CarsSold {...
11
by: Neo Geshel | last post by:
I have an Access DB, from which I am going to pull images. Each image has an associated ID, but the ID's are not necessarily sequential (some images may have been deleted, leaving gaps in the list...
4
by: ja | last post by:
Hello all, How can I ramdomly select a list of records from an existing table? For example: 500,000 names divided by 20,000 samples = 25. The N is 25, meaning samples would be sent to every...
17
by: glenn.robinson | last post by:
Hello, DB2 for iSeries - V5R2 I have a table with a non-unique index, column name SEDOL. I need to extract the 2nd row from each set of SEDOL rows in the table. If only one SEDOL row exists...
29
by: pb648174 | last post by:
I have the following basic statements being executed: Create a temp table, #TempPaging Insert Into #TempPaging (Col1, Col2) Select Col1, Col2 From SomeOtherTable Order By Col2, Col1 Select...
8
by: Jimbo | last post by:
Hello I am currently designing an internal ordering system for IT equipment. I am designing it in ASP.NET (vb) using Visual Studio 2003 and using Microsoft SQL Server I have got the system...
48
by: Jimmy | last post by:
thanks to everyone that helped, unfortunately the code samples people gave me don't work. here is what i have so far: <% Dim oConn, oRS, randNum Randomize() randNum = (CInt(1000 * Rnd) + 1) *...
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
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,...
0
jinu1996
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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 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.