Solved

Microsoft Access 2010 Add a -1 to 20130001 now may be 20130001-1

Posted on 2013-11-30
12
269 Views
Last Modified: 2013-12-09
I have a table tblrecordlog.  I have a key field but also have a recordnumber in the format the client was using manually before for example 20139999.  I have this number as a double now. The client would like to be able to add a record and a decision would later be made to possibly break up the project into multiple records. They want 20139999-1 for example. Do I set up another table? Do I to change the format of the field? Not each project will be divided. The -1 record would be independed of the original record or maybe I can delete the original record and have them all start out all records with -1.. I am not sure if I like that or not. Can someone give some insight. Thanks.
0
Comment
Question by:marlind605
  • 6
  • 4
  • 2
12 Comments
 
LVL 39

Expert Comment

by:als315
ID: 39686978
You can convert recordnumber field to text and use it. Sometimes better to have separate field for project, in this case you can add index for this field and queries can work faster. On forms number and project can be combined.
You should give us more details about DB, if you like to get qualified answer.
I prefer not to use double for numbers without decimal part
0
 
LVL 34

Expert Comment

by:PatHartman
ID: 39686990
If the copied project is completely independent of the project it was copied from, then you would just assign a new number.  The -1 implies that there is some relationship.  If there is a relationship, then the better solution would be to create a new table that can be used to group projects.  You would still assign a new ID.
0
 

Author Comment

by:marlind605
ID: 39687150
I do have a seperate number for the index field. The record number is generated by YYYY#### #### being 0001 0 - 9999 My vision is to click on a button on a form correspending to the original record. The button will copy all of the record and the user would change the details to the way they need to. I can change the field to text but I am not sure how to add a -1 based on the recordnumber now text. And it could start with -1 and go to 99 for example. 20130001-1 to 20130001-99.
0
 
LVL 39

Accepted Solution

by:
als315 earned 250 total points
ID: 39687233
You can always generate string from parts. In your case it will be something like:
=RecordNumber & "-" & ProjectNumber
if RecordNumber is text. If it is numeric, you can add format:
=Format(RecordNumber, "00000000") & "-" & ProjectNumber
0
 
LVL 34

Expert Comment

by:PatHartman
ID: 39687238
If the records are not related once they are split, why do you need to add a suffix to the ID field?  Why not just assign the next available number?   If you wanted to track the source, simply add another column to the table where you can store the original ID.  I would use the autonumber PK rather than the generated number for this purpose.
0
 

Author Comment

by:marlind605
ID: 39687364
The client wants it this way.
0
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.

 

Author Comment

by:marlind605
ID: 39687366
A request will come in the form of an email etc and there may be multiple steps in the request.
0
 
LVL 34

Expert Comment

by:PatHartman
ID: 39687635
If the projects are related, you do "A", if they are not related you do "B".    Sounds like they are related and that requires a structure change so you can group them.  Add an additional column for the suffix because you will now have a second field to increment unless you are going to allow the user to specify the suffix.
0
 

Author Comment

by:marlind605
ID: 39692827
RIght now I am using a NZ(Dmax) to generate my current number it places the currentyear in front of a sequencial number based on records that is already in the table. in the table. How do I generate a new number that shows 200130001-1 20130001-2 20130001-3 .... based on 20130001 already in the table. Now all I want to do is allow the user to add another record copy that record and it looks in the table for matching prefix numbers and add another sequence.
0
 
LVL 34

Assisted Solution

by:PatHartman
PatHartman earned 250 total points
ID: 39693361
When you construct "meaningful" IDs, they should have meaning.  If you will ever want to join the various 20130001 records, you need to put the suffix into a separate column or pay the price later.  If you don't think you would EVER need to bring these records together then, what in the world is the suffix all about?  Adding a second column for the suffix will also mean that you need to add an additional column to the unique index on this field.  Set the default for the column to 0.  After you add the column, you will need to run an update query to replace all null values with 0.  If you prefer to start with 1 rather than 0, then make 1 the default and replace the nulls with 1's.  You'll need to fix the data before you alter the index to avoid duplicates.
0
 

Author Comment

by:marlind605
ID: 39698071
PatHartman
The whole purpose of this database is to track records request that is the reason for the name. I have added a field supplemental. Each record does have a never seen by the user ID number auto-number key field. I have created a form that when the user wants to split the request they can do so. The user specifically requested to keep the record number and add-1 to what maybe 1 or multiple split events. So I seem to be looking at a DMAX + 1 solution to see if this solution would work and use the update query like you suggested. I am thinking out loud now. Today I need to make a form where the user clicks add supplemental. Database will copy record assign a new unique number. I need to have it show the 20130001 with a -1 for the new record. Hope this helps. I will be looking at what I can do with this today.
0
 

Author Comment

by:marlind605
ID: 39698523
I got it. I will be awarding points later today. No more answers required. Thanks.
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

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
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…

705 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

17 Experts available now in Live!

Get 1:1 Help Now