Solved

Autonumber Format

Posted on 2009-07-07
3
382 Views
Last Modified: 2013-11-28
Hi Experts,

I'm having a table that has a primary field as auto number. I want to add year to this field and have it reset after each year. Can anybody help me with this please?
 
Currently it's format as 0"8-"000 but I want it to be using a datetime field called DateofService and use the year mentioned there and create/append the autonumber

For example: DateOfService: 05/01/2007 then GC # 07-001 and if there are other records for that year it should increment it sequentially. If the year changes it should reset and start with the same (05/01/2008 08-001).

Thanks

Table name: TBL_BCInformation

Fields: GC # (primary key) autonumber

           DateofService Datetime

Open in new window

0
Comment
Question by:Samoin
  • 2
3 Comments
 
LVL 84
ID: 24799671
You cannot format an Autonumber field. You can create sequential numbers for each year, but you cannot do this at the table level. You must do it through your forms.

Do you have multiple users in this database? If you do, the task is much more involved.
0
 
LVL 1

Author Comment

by:Samoin
ID: 24803642
Hi LSMConsulting,

Can you show how I can create a custom sequential number that can be used as primary key? Yes I do have multiple users in this database.

Thanks
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 24804203
That's a broad topic - multiple users with a customized number. You can't just use DMax, since it's entirely possible that two users will be building a new record at the same time. Here's some light reading on the subject:

http://support.microsoft.com/kb/210194
http://support.microsoft.com/kb/191253
http://www.tek-tips.com/faqs.cfm?fid=4634

In regards to your format, you'd be better off building that as needed. You're already storing the date your record is created; if you also store a "sequence" number that is relative to your Year, you can then build your "ID" key as needed. For example, if I have a column in my table named "lSequence", and my date field is named "dServiceDate", on my form I can do this:

Me.YourIDField = "GC # " & CStr(Year(dServiceDate)) & "-" & CStr(Me.lSequence)

Your lSequence field would be, basically, your "counter" in the link examples above. Each time a user needed to add a record, you'd have to grab the next value and use it.
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now