Results 1 to 2 of 2
  1. #1
    fpmsi is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    16

    Code Generator

    Looking to be pushed in the right direction for creating a code generator for a file after import.

    The code is made up of 3 parts: (900-000000-0099)
    900 = Client Code - would be taken from a lookup table
    000000 = month and year of import (082011)
    0099 = numerical sequence (needs to be the next sequence number in line from the table.



    Thanks


    Ryan.

  2. #2
    Bob McClellan is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Sep 2011
    Location
    New Jersey
    Posts
    17
    [IMG]Y:\Temp\immediate.jpg[/IMG]Function test() As String
    'The code is made up of 3 parts: (900-000000-0099)
    '900 = Client Code - would be taken from a lookup table
    '000000 = month and year of import (082011)
    '0099 = numerical sequence (needs to be the next sequence number in line from the table.



    Dim p1 As String, p2 As String, p3 As String

    p1 = CStr(900)

    test = p1

    p2 = CStr(Month(Date))
    If Len(p2) = 1 Then
    p2 = "0" & p2
    End If

    p2 = RTrim(p2) & CStr(Year(Date))

    test = RTrim(test) & RTrim(p2)


    'p3 = 'here, create a function that gets the max(PK) number from your table & set p3 = that number + 1
    'I will use the 0099 to finish the string...

    p3 = CStr(99)

    test = RTrim(test) & RTrim(p3)


    End Function
    '----------------
    from immediate window...
    this is returned..
    ? test
    90009201199

    hth,
    ..bob

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

Similar Threads

  1. Word code in Access - How to modify my current code
    By Alexandre Cote in forum Programming
    Replies: 0
    Last Post: 11-15-2010, 08:26 AM
  2. Code in combobox, code in text box
    By float in forum Forms
    Replies: 3
    Last Post: 09-29-2010, 07:12 AM
  3. Sorta Random Serial Number Generator
    By Cuselco in forum Programming
    Replies: 3
    Last Post: 08-27-2010, 12:05 PM
  4. how to get to the raw code
    By YankeeImperialistDog in forum Programming
    Replies: 1
    Last Post: 03-05-2010, 01:55 PM
  5. Access 2003 code vs Access 2007 Code
    By ralphjramirez in forum Access
    Replies: 5
    Last Post: 11-23-2009, 12:33 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