Results 1 to 4 of 4
  1. #1
    tareyj8569 is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Aug 2009
    Posts
    43

    Custom Auto Field on form

    Hi there,

    The goal is to still have my normal primary key that goes up by 1, but I want another field that will look like ABC14-0001 and goes up by one every record. The 14 is the year and I would like it to reset back to ABC15-0001 but in October1st and so on every year.



    I would like it to show on the form.

    I have been looking for days and tried multiple sites, if any one can help me with this I would really appreciate it. I do not care how it is accomplished as long as it works=P.


    Thanks for your time and help.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Maybe the on current event of a form. This example uses a textbox control named txtResult and assumes the field you are using has a control named MyID


    Code:
    Dim strPred As String
    strPred = "ABC" & Format(Date, "yy") & "-"
    Me.txtResult.Value = strPred & Me.MyID.Value

  3. #3
    tareyj8569 is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Aug 2009
    Posts
    43
    Thanks for responding, thats not 100% what I am looking for. What I am looking for is actually a few things.
    1. for it to have ABC
    2. 2 digit year 14-
    3. to have its own count 0001
    4. than in October not January to restart the count
    So on October 1st it would look like ABC14-0001.
    I am not the best at access but am trying to learn if there is a way i can use what you suggested to get what I am trying to accomplish i am defiantly listening.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    First thing would be to make sure that, come Oct 1st, Everyone agrees that October 15, 2014 is FY2014 and not FY2015.

    I would probably dedicate a table to creating the sequence. You could use an Autonumber field to create the number sequence part. Another approach would be to use DMax to find the greatest and +1 to append. Index the column that is the series and use error trapping for your append process to catch possible duplicates (in case two users retrieve the same DMax).

    The trick is resetting the count every FYS. I would run an automated process (once a year) with task scheduler to delete the records within the counter table and do a compact and repair or just compact. Since you need an automated process and probably do not want to delete all records while multiple users are working, might as well use Autonumber and run the maintenance at night 0:30 hrs Oct 1.

    With the autonumber part addressed, it is just a matter of adjusting the expression to return 14 on Feb 10, 2015.

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

Similar Threads

  1. Custom Auto Number (somewhat complex)
    By pjd71 in forum Access
    Replies: 1
    Last Post: 05-19-2013, 11:24 AM
  2. Replies: 3
    Last Post: 10-03-2011, 02:33 PM
  3. Auto complete field on form
    By oam in forum Access
    Replies: 5
    Last Post: 09-23-2011, 12:45 PM
  4. Auto populate a field (without a form)
    By DonL in forum Access
    Replies: 1
    Last Post: 06-21-2011, 03:19 AM
  5. Custom & Auto Incrementing Job Number
    By mastromb in forum Programming
    Replies: 1
    Last Post: 01-05-2010, 02:58 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