Results 1 to 4 of 4
  1. #1
    Cuselco is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    2

    Question Sorta Random Serial Number Generator

    Please speak to me as a child since I am a complete tool with access, and know just enough to get by :-)
    I have created a basic database with only a couple tables. In the main table which I have created a form to fill some information and some items look up from another table ect. . . . No problem. But, what I would like to do is have a button that automatically generates a serial number on the main form for that record when clicked. It would be nice to have 2 seperate buttons for 2 seperate fields for this serial number generator.

    The format that I would like it to follow would be
    ( for serial generator 1 )

    WWYYY-P-88-ZZZ
    Example: Where the WW is the current year, 20"10" YYY is the day number of the same year (Julian day?), P and 88 is static and ZZ would be a progressive number that would reset every day beginning at 001.
    so, 10208-P-88-001 would be the first product produced on Aug 28 2010, or 10210-P-88-015 would be the 15th products produced on August 30, 2010 and so on. . .

    ( for serial generator 2 )
    The same, except the P-88 statics would be replaced with S-5.



    Is this making sense?
    Thanks for any and all help in advance!

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    assume your table name is "TableName", serial number field name is "SN", textbox1 is the control you want to put the serial number.

    use following code in the click event of a botton.

    Private Sub Command2_Click()
    Dim serialNo As StringFormatEnum
    serialNo = Format(Now, "yy") & Format(DatePart("y", Now), "000") & "-P-88-"
    serialNo = serialNo & Format(Nz(DMax("SN", "tableName", "SN like '" & serialNo & "*'"), "0"), "000")
    textbox1 =serialNo
    End Sub

  3. #3
    Cuselco is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    2
    Just tried it..... when i click the button (command2) I get the error-
    "Compile Error - User Defined type not defined" ??
    This was highlighted in the vb code:
    serialNo As StringFormatEnum

    Something I did wrong?

  4. #4
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    remove the red thing. it's a typo.

    Private Sub Command2_Click()
    Dim serialNo As StringFormatEnum
    serialNo = Format(Now, "yy") & Format(DatePart("y", Now), "000") & "-P-88-"
    serialNo = serialNo & Format(Nz(DMax("SN", "tableName", "SN like '" & serialNo & "*'"), "0"), "000")
    textbox1 =serialNo
    End Sub

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

Similar Threads

  1. Automatic Serial Number in Report
    By jamil_kwi in forum Reports
    Replies: 11
    Last Post: 01-19-2015, 11:09 AM
  2. Help On Creating Automatic of a Serial Number
    By lm_lopes in forum Programming
    Replies: 4
    Last Post: 03-10-2010, 06:47 AM
  3. Random number generators with no repeats
    By CJ508 in forum Access
    Replies: 5
    Last Post: 10-29-2009, 07:30 AM
  4. Auto Sequence String Serial Number
    By eddyc99 in forum Programming
    Replies: 2
    Last Post: 10-02-2009, 08:11 AM
  5. Replies: 5
    Last Post: 02-08-2006, 08:42 PM

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