Results 1 to 3 of 3
  1. #1
    forbesk is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2016
    Posts
    2

    Need to find a specific set of numbers in a record set and increment them by 0.000001

    Hello everyone,
    I inherited this database that is used by my department. Condition IDs are numbers such as 1.00005 1.00006, each number means something to someone, but nothing to me. The users have asked me to create routine that will resequence these numbers from specific spot. For example, I need to add a condtion between condition 1.00005 and 1.00006, so let's have a new condition inherit the 1.00006 number and every number after, that begins with 1 needs to be renumbered.

    Stop when you get to number 2.
    This is what I have so far: My two big problems:
    * Can not get variables to work for the beginning and ending numbers (Right now I have actual numbers in there as placeholders)
    * Can not get the records to Increase by 0.000001 (The numbers are either replaced by 0.00001 or they switch to increasing from 0.00000 instead of whatever numbers I have set as the begin and end numbers.
    Code:
    Private Sub Test_Click()
    Dim dbs As DAO.Database
    Dim rstConditions As DAO.Recordset
    Dim strSQL As String
    Dim intI As Integer
    Dim LConditionID As Double
    Dim LRound As Integer
    Dim CurrentNumber As Double
    
    
    
    
     LConditionID = InputBox("Please enter the first condition number that has to be resequenced.", "Renumber condtion IDS")
     LRound = Round(LConditionID) + 1
     
    On Error GoTo ErrorHandler
    
    
       Set dbs = CurrentDb
    
    
       'Open a recordset on all records from the Condition table that have
       'a value that is equal to the input box.
       strSQL = "SELECT * FROM Condition WHERE (((Condition.ConditionID)>=7.000001 And (Condition.ConditionID)<=8.000001));"
       Set rstConditions = dbs.OpenRecordset(strSQL, dbOpenDynaset)
    
    
      
       'If the recordset is empty, exit.
       If rstConditions.EOF Then Exit Sub
    
    
       intI = 1
          With rstConditions
          Do Until .EOF
             .Edit
             ![ConditionID] = [ConditionID] + 0.000001
             .Update
             .MoveNext
             intI = intI + 1
          Loop
       End With
    
    
       rstConditions.Close
       dbs.Close
    Thanks in advance for any help.


    Kim

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Not clear what you want.

    If you have values like 1.00005 & 1.00006 (5 decimals), do you want to increment the two numbers to
    1.00006 & 1.00007 (5 decimals)
    or
    1.000051 & 1.000061 (6 decimals)?

    Examples would be nice;
    what you have & what you want........




    This line
    Code:
             ![ConditionID] = [ConditionID] + 0.000001
    should be
    Code:
             ![ConditionID] = ![ConditionID] + 0.000001
    Note the bang (!) in front of the 2nd "ConditionID".


    Edit: Maybe something like the attached dB?
    Attached Files Attached Files

  3. #3
    forbesk is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2016
    Posts
    2
    Thanks Steve,
    It is actually 6 decimals to 6 decimals--I had to recount the zeros. Worked perfectly thanks.

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

Similar Threads

  1. Replies: 6
    Last Post: 08-26-2014, 06:23 AM
  2. Find specific record in subreport
    By hpHHI in forum Reports
    Replies: 1
    Last Post: 05-24-2013, 03:14 AM
  3. Trying to find a specific Record using VBA
    By FormerJarHead in forum Programming
    Replies: 26
    Last Post: 11-12-2012, 07:11 PM
  4. Replies: 1
    Last Post: 02-23-2012, 11:48 AM
  5. Renumbering Auto-Increment numbers
    By svcghost in forum Database Design
    Replies: 8
    Last Post: 02-19-2011, 08:48 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