Solved

AutoNumber

Posted on 1998-10-06
5
481 Views
Last Modified: 2008-03-06
Have a old database with 4000 records from last fiscal year, need to start new fiscal year to same database, but want to add a autonumbering field.  The autonumbering sequence automatically counts all previous records.  I need to start a "0000" new sequence to the new FY without it taking in to affect the previous year... Help!
0
Comment
Question by:drew77
5 Comments
 
LVL 3

Expert Comment

by:vmano
Comment Utility
refer to the previously asked questions in EE.
http://experts-exchange.com/topics/comp/lang/vbdatabases/Q.10084353

let me know if this helps
vmano
0
 
LVL 1

Expert Comment

by:ghjm
Comment Utility
If I understand you correctly, you are saying you want a field that shows zero or null for records from prior years, but shows an incrementing autonumber starting at the beginning of this year.

There is no way to make an autonumber behave like that on a single table. However, what you can do is create two tables and then use a union query to make them appear like a single table for purposes of reporting, etc.

For testing, I created two tables. One has two string fields, "key" and "value". The other has the same two fields plus an autonumber field called "seq". The following SQL query will return a single result set that gives all data with zero values for "seq" for records that came from the old table:

SELECT key, value, 0 AS seq FROM TABLE1
UNION SELECT key, value, seq FROM TABLE2;

The problem with this approach, of course, is that queries are read-only. However, I assume that your prior year data is closed out and won't be changed at this point, so it might be acceptable to point your data entry screens at the new table and simply ignore last year's data. Reporting is no problem because reports can run off queries.

Hope this helps...

-Graham
0
 
LVL 1

Expert Comment

by:ghjm
Comment Utility
If I understand you correctly, you are saying you want a field that shows zero or null for records from prior years, but shows an incrementing autonumber starting at the beginning of this year.

There is no way to make an autonumber behave like that on a single table. However, what you can do is create two tables and then use a union query to make them appear like a single table for purposes of reporting, etc.

For testing, I created two tables. One has two string fields, "key" and "value". The other has the same two fields plus an autonumber field called "seq". The following SQL query will return a single result set that gives all data with zero values for "seq" for records that came from the old table:

SELECT key, value, 0 AS seq FROM TABLE1
UNION SELECT key, value, seq FROM TABLE2;

The problem with this approach, of course, is that queries are read-only. However, I assume that your prior year data is closed out and won't be changed at this point, so it might be acceptable to point your data entry screens at the new table and simply ignore last year's data. Reporting is no problem because reports can run off queries.

Hope this helps...

-Graham
0
 

Author Comment

by:drew77
Comment Utility
Sorry, VMANO...  The previously answered question refers only to a start number base.  What I need is a autonumbering sequence on the same table.  Furthermore, I have received other suggestions to suggest combining two tables and using a union query to act as one.  I tried that before, but was just missing it somewhere.  I've gotten some suggestions on that same option...I'll be trying that.  Thanks again....

Drew...
0
 
LVL 1

Accepted Solution

by:
rholmes earned 100 total points
Comment Utility
Set both fields to Long Integer fields. That will lock FY1 fields and discontinue the counting. Set the DefaultValue on FY2 to =DMax+1.Since its a Long Integer field it should start the numbering @ 1, etc.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

743 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

16 Experts available now in Live!

Get 1:1 Help Now