Results 1 to 7 of 7
  1. #1
    sdl2 is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    Feb 2015
    Posts
    4

    Determine remaining values from input like 1,2,3-10,11,13-15

    I think this may be a very hard problem. I have a database which has a part number and that part number has a certain number of holes. This value is known but can range from 0 to 200. These holes get springs based on input from the user. For example, the part has 15 holes


    Spring 1: 1,2,3-10
    Spring 2: 11
    Spring 3:
    Spring 4: 13-15
    Spring 5:

    I am looking for a way to input this in access so that access recognizes that 3-10 means 3,4,5,6,7,8,9,10.
    I need it to be able to tell what positions are missing or duplicated. In this example 12 is missing.

    Please help or suggest alternatives. Typing 1,2,3,4,200 10x a day is not going to work and is very prone to errors. A list can not work either as 25 positions has choose 13 has over 5,000,000 combinations

    Thanks

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,737
    So, trying to fill in the description, you seem to have:

    An unknown number of Parts or Pieces each of which may have from 0 to 200 holes. The holes on a Part/Piece are identifiable. And you have a finite number of Springs or types of Springs that may be assigned to 0 or more holes in any Part/Piece.

  3. #3
    sdl2 is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    Feb 2015
    Posts
    4
    Quote Originally Posted by orange View Post
    So, trying to fill in the description, you seem to have:

    An unknown number of Parts or Pieces each of which may have from 0 to 200 holes. The holes on a Part/Piece are identifiable. And you have a finite number of Springs or types of Springs that may be assigned to 0 or more holes in any Part/Piece.
    Yes orange, that is correct. There are 5 possible springs, not all are required. Each record has 1 part and on that record the spring information needs to be filled in. I know how many holes each part has, that information is stored in a field.

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,737
    I am attaching a draft data model that may be useful to you as a starting point.
    If it isn't applicable, then please ignore it.
    Good luck with your project.
    Attached Thumbnails Attached Thumbnails PartsAndSprings.jpg  

  5. #5
    sdl2 is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    Feb 2015
    Posts
    4
    Quote Originally Posted by orange View Post
    I am attaching a draft data model that may be useful to you as a starting point.
    If it isn't applicable, then please ignore it.
    Good luck with your project.
    Hey orange,
    Thank you for this, do you have any idea about how to approach the calculation. Let's just assume 11 holes. To translate a user input 1,3-10,11 for access to interpret it as 1,3,4,5,6,7,8,9,10,11 and realize that position 2 is missing? This is where the struggle is, how to accomplish this.

  6. #6
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,737
    You could try to adapt a Select Case construct.
    http://www.techonthenet.com/access/f...anced/case.php


    Code:
    For testValue = 1 to 11
      Select Case 
      Case 1
      'do whatever for case1 perhaps assign Spring100
       Case 3 to 10
      'do whatever for case3,10 perhaps assign Spring105
      Case 11
      'do whatever for case11 perhaps assign Spring110
      Case Else
      'This could pick up the numbers not explicitly identified
      '  for example you could test values from 1 to your Max eg 11
        'this would identify 2 as missing
        debug.print testValue
    
        End Select 
    Next TestValue
    If you have a few test cases, then perhaps a user defined function could be built. Need more details/examples.

  7. #7
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,445
    providing your users are consistent in their input - i.e. always separate values with a comma and no spaces either side of the '-' (although you could resolve those in code) you could manipulate and array

    for a user input 1,3-10,11
    Code:
    function ExpandNumbers(input as string) as string
    dim Arr1() as string
    dim Arr2() as integer
    dim I as integer
    dim j as integer
    dim k as integer
    
        arr1=split(input) 'to divide into separate elements
        j=0
        for i = 0 to ubound(Arr1)-1 'step through each element
             if instr(arr1(I),"-")=0 then 'just a number
                 arr2(j)=val(arr1(I))
                 j=j+1
             else 'there is a range of numbers
                 arr2(j)=val(arr1(I))
                 k=arr2(j)+1
                 j=j+1
                 while k<=val(mid(arr1(I),instr(arr1(I),"-")+1)
                      arr2(j)=k
                      j=j+1
                      k=k+1
                 wend
    
            end if
        next I
    
        ExpandNumbers=""
        for I=0 to ubound(arr2)-1
            ExpandNumbers=ExpandNumbers & arr2(I) & ","
        next I
        
        ExpandNumbers=left(ExpandNumbers,len(ExpandNumbers)-1)
    
    end function

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

Similar Threads

  1. Replies: 1
    Last Post: 10-16-2013, 07:57 PM
  2. Table Values from combo Box Input
    By Kennertoy in forum Access
    Replies: 8
    Last Post: 03-16-2013, 11:43 AM
  3. Using Like to prompt input of multiple values
    By eskybel in forum Queries
    Replies: 6
    Last Post: 01-16-2013, 03:45 PM
  4. display a list of values based on user input
    By karl1971 in forum Access
    Replies: 3
    Last Post: 12-06-2011, 09:19 AM
  5. Table Values As Query Input?
    By joolio in forum Access
    Replies: 2
    Last Post: 01-05-2010, 07:32 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