Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2008
    Posts
    2

    Unanswered: Autonumber problem

    This is a pretty basic question but anyways,

    I'm making a a bank application that automatically creates bank account numbers. The number is set to being a random autonumber, and also set to a long integer. The problem is that some numbers are being created as negative values. Does anyone know how to set the results to being all positive? Maybe by entering something into the format field?

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    abs() function returns the absolute number, removes any negatives

    what seed are you using for your account number generation?
    what statement are you using to generate your number?
    what has autonumber to do with random number?

    BTW: I would have thought an account number will be sequential, with a check digit embedded somewhere in the number...

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    A random number generator won't get you any extra marks on your assignments

    I don't see why you've not used a simple Autonumber field as opposed to your own custom function.
    George
    Home | Blog

  4. #4
    Join Date
    Feb 2008
    Posts
    2
    Quote Originally Posted by georgev
    A random number generator won't get you any extra marks on your assignments

    I don't see why you've not used a simple Autonumber field as opposed to your own custom function.

    It is a simple Autonumber field, The datatype associated with the field is a long integer. Its just when its set to random as opposed to increment, the number goes both directions. I could just use increment from a number like 1000000, but then the numbers would be pretty unlike ones we use for bank accounts?

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so whats thew problem
    are you trying to recreate bank accoutns, or are you trying to fake accout numbers for an assignment.

    if you want to fake the account number then add some garbage tot he front of the number.. say a check digit(s)..... that way round account number 1, may come out as 8000000001.

    if its purely for an assignment then I'd wouldn't bother with with such fripparies.. the assignment is meant to be an assessment of how well you understand the material presented to you, and how much work you have done off your own bat.

    It doesn't have to replicate the banks approach, it just has to hang together as a system. a\fter all its not real life but an assignement

    autonumber is in my books the way to go

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Bank acount numbers are text anyhow, not numbers
    01234-56789

    The heifen and posiblity of leading zeroes make it a number stored as text.
    Take your autonumber and when you need to display it to a user pad it with zeroes and, if required, a check digit.
    Code:
    Function displayAcountNumber(ByVal theAutoNumber As Integer) As String
        Dim AccNum As String
          AccNum = "0000000000000" + CInt(theAutoNumber)
          AccNum = Right(AccNum, 12)
    
          displayAccountNumber = AccNum
    End Function
    The above is untested code, but should give you an idea
    George
    Home | Blog

Posting Permissions

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