SitePoint Sponsor

User Tag List

Results 1 to 11 of 11

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2001
    Location
    Belo Horizonte, Brasil
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Autonumber Generatade numbers

    Hi,

    I'm putting togheter a e-store and want Acess to generate the order numbers. The simple increment is bad because it only generates numbers like 1,2,3 ect. Then I tried the ramdom number thing and the numbers that come out now are like : 5700399, 10033334,
    -5710399, -10033334. I just don't want negative numbers to come out. Anyone knows how to format those generated numbers?

    Thanks!

  2. #2
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try:
    Code:
    cInt(number here)

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2001
    Location
    Belo Horizonte, Brasil
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure where to put that code...
    The 'new value' box doesn't alow me to put it there.

  4. #4
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Uhm... you talking about with ASP or just with Access?

  5. #5
    SitePoint Enthusiast
    Join Date
    Feb 2001
    Location
    Belo Horizonte, Brasil
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just Acess. In the autonumber properties, there's 3 fields to set:
    Field Size : I choosed Long Int
    New Values : Ramdom
    Format : nothing

    The format thing doesn't work for me. I tried ABS(number) and nothing, negative numbers still come out.

  6. #6
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does it have to be a numbe? If not, you could make an repulcation ID, which generates a random string, tho it contains letters and stuff.


  7. #7
    SitePoint Enthusiast
    Join Date
    Feb 2001
    Location
    Belo Horizonte, Brasil
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no it doesn't have to be a number, but the replication is kindo of too long I think.

  8. #8
    Say WHA?! goober's Avatar
    Join Date
    Sep 2000
    Location
    United States
    Posts
    1,921
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe you should try it like this?
    Code:
    val1 = |val2|
    lol nothing to support it, i dunno if it'll work, but it's worth a shot.
    Sean Killeen [LinkedIn] [Twitter] [Web]

    Warning: Reality.sys corrupted. Universe halted. Reboot? (Y/N)

  9. #9
    SitePoint Wizard big_al's Avatar
    Join Date
    May 2000
    Location
    Victoria, Australia
    Posts
    1,661
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I personaly wouldn't suggest using random numbers for invoices as VB's random numbers....aren't so random

    But if you really want some random number that are good for using in invoices then here is a little script I somtimes use

    Code:
    Randomize
        function ZeroPad(sWork, nDigits)
        	ZeroPad = right(string(nDigits, "0") & trim(sWork), nDigits)
        End function
        function GetIndexNumber()
        	sDay = Day(Now())
        	sMonth = Month(Now())
        	sYear = Year(Now())
        	sHour = Hour(Now())
        	sMinute = Minute(Now())
        	sSecond = Second(Now())
        	Tail = Int(1000000 * Rnd)
        	GetIndexNumber = ZeroPad(sYear, 4) & ZeroPad(sMonth, 2) & ZeroPad(sDay, 2) & ZeroPad(sHour, 2) & ZeroPad(sMinute, 2) & ZeroPad(sSecond, 2) & ZeroPad(Tail, 6)
        End function
    .NET Code Monkey

  10. #10
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, I would go with what Al said. When ever I need to generate random numbers, I always found that using the time the best way to go. And some times a lil of the IP number.

  11. #11
    SitePoint Wizard big_al's Avatar
    Join Date
    May 2000
    Location
    Victoria, Australia
    Posts
    1,661
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Never thought about using IP as well, great idea, might have to use that next time
    .NET Code Monkey


Bookmarks

Posting Permissions

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