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?
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?
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
Bank acount numbers are text anyhow, not numbers
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.
Function displayAcountNumber(ByVal theAutoNumber As Integer) As String
Dim AccNum As String
AccNum = "0000000000000" + CInt(theAutoNumber)
AccNum = Right(AccNum, 12)
displayAccountNumber = AccNum
The above is untested code, but should give you an idea