Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2002
    Location
    Houston, Texas
    Posts
    74

    Unanswered: assigning account numbers

    I am working on a school project and today is the deadline. I have a subform "frmSub2" (bounded form table is tbldist)
    in tbldist i have studentID, StartNum and EndNum (they are all number). The form is for teacher who will assign students account

    numbers. see below for sample. I need to add a button which will validate that no overlapping is going on. Also, i need to validate

    the very number is assigned is 0. also, you can student # 1 will handle accounts from 00 to 11 , student#2 will handle accounts that

    start with 12 and end with 20 (student# 2 did not start with 11 cause student # 1 has it). Hope its making sense.

    StudentID StartNum EndNum
    1 00 11
    2 12 20
    3 21 26
    4 27 33
    5 34 52

  2. #2
    Join Date
    Dec 2002
    Location
    Houston, Texas
    Posts
    74
    i was given this piece of code but it's a mess and never worked.

    ‘ This function checks for duplicate, missing, inverted, & invalid numbers from range 00 – 99.
    ‘ The numbers are assumed existing in 2 columns.
    ‘ As numbers are assigned, array intFilled will have a –1 put into each assigned number’s cell.

    Public Function Valid_Range() as Boolean

    Dim intNum1(0 to 99) as integer, intNum2(0 to 99) as integer
    Dim intFilled(0 to 99) as integer ‘ contains –1 for each assigned number
    Dim intNRows as integer ‘ number of rows user has assigned
    Dim intNCt as integer ‘ counter for Num arrays (user-input numbers)
    Dim intFCt as integer ‘ counter for Filled array
    Dim rstDistLevel as RecordSet ‘ table containing user-input number ranges

    Valid_Range = true
    rstDistLevel = dbname.OpenRecordSet(“DistLevel”, dbOpenTable)

    ‘ Check to make sure some numbers exist
    If intNRows < 1 then ‘ number of user-entered rows
    Msgbox “At least one range must be entered.”
    Valid_Range = false
    Exit Function
    End if

    rstDistLevel.MoveFirst
    intNCt = 0
    Do until rstDistLevel.EOF
    intNum1(intNCt) = rstDistLevel!BegAssign ‘ first num (field) in range
    intNum2(intNCt) = rst DistLevel!EndAssign ‘ last num (field) in range
    rstDistLevel.MoveNext
    intNCt = intNCt + 1
    Loop

    ‘ Loop through number of rows
    For intNCt = 0 to intNRows-1
    ‘ Check for inverted numbers
    If intNum1(intNCt) > intNum2(intNCt) then
    Msgbox “Row “ & intNCt+1 & “: The first number cannot be greater than the second number.”
    Valid_Range = false
    Exit Function
    ‘ Check for invalid numbers
    Elseif intNum1(intNCt) < 0 or intNum2(intNCt) < 0 or intNum1(intNCt) > 99 or intNum2(intNCt) > 99 then
    Msgbox “Row “ & intNCt+1 & “: Number must be 0 through 99.”
    Valid_Range = false
    Exit Function
    End if

    ‘ Loop through previously assigned numbers
    For intFCt = intNum1(intNCt) to intNum2(intNCt)
    ‘ Check for duplicate (overlapping) number
    If intFilled(intFCt) = -1 then ‘ number already assigned
    Msgbox “Row “ & intNCt+1 & “ contains a duplicate number.”
    Valid_Range = false
    Exit Function
    End if
    IntFilled(intFCt) = -1
    Next
    Next

    ‘ Check for missing (unassigned) numbers
    For intFCt = 0 to 99
    If intFilled(intFCt) <> -1 then
    Msgbox “Number “ & intFCt & “ has not been assigned.”
    Valid_Range = false
    Exit Function
    End if
    Next

    End Function


    ---------------------------------------------------------------------------------
    ‘ Call function to validate number range

    If not(Valid_Range) then
    ‘ Error msg already displayed. Do not save.
    ‘ Leave user on this screen until s/he correctly assigns numbers or cancels.
    End if

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •