473,385 Members | 1,521 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Primary Key need to be reconfigured to AutoNumber without changing the Field Data Typ

Here is the thing guys :)
I started a access DB with more than 700 hundred records.
I have CusID Field which is a primary Key in VIPsInfo table and foreign Key in other tables.
My problem now is i made the CusID data type (Short Text) and i used to enter it manually.
I am looking for changing my manual entry to an Auto numbering or auto filling .
i know it was a stupide thing for me to do it at the first place and foolish thing to hope it can be fixed after 700 hundred records.
one more thing my CusID sequence is "CUS0001,CUS0002...CUS0700..."
i think this is everything :D
Oct 26 '15 #1
4 1241
NeoPa
32,556 Expert Mod 16PB
An AutoNumber field contains Long Integers.

It is not even possible to hold text values, such as the ones you mention, in such a field.
Oct 26 '15 #2
jforbes
1,107 Expert 1GB
NeoPa is right, AutoNumber isn't going to work for you.

You could leave it as Text and then use a routine to return the next Key for the Default Value of the field on a Form. There is an example of one here: http://bytes.com/topic/access/answer...mber-data-type
Oct 27 '15 #3
Ok. This is probably silly as the other two guys who have commented know WAY more than I do. But here are two ideas, if I understand your goal correctly.

Both involve adding an autonumber field and then removing the now redundant short text field.

You could use a standard prefix "CUST" and then the autonumber field and eliminate the short text entirely. This doesn't change the underlying data type (long) but just puts your text in front. Here is an old example. http://www.databasedev.co.uk/add_prefix.html

You could work only on a form and make a label control with the appropriate information formatting. Again, your underlying field remains long and you just read from the autonumber and change the display. (This is another version of what jforbes has suggested.)

You would lose your data you have entered in the CusID field. But it would be replaced by the new autonumber field.
Oct 27 '15 #4
zmbd
5,501 Expert Mod 4TB
lonlyspartakos, I feel your pain.
In the dark past I've done such a thing, just to have a similar event happen. Lesson I learned here, don't use the primary key for anything other than as a unique record ID.

The issue with the article given in CW post (#4) is that the underlying autonumber is the stored value - hiding the true data, IMHO, not best practice.

To clarify.
In the article cited, for the autnumber field, the ["EMP"0000] format is given. The resulting displayed value in the table is EMP0001, EMP0002, EMP0003,... EMP9998, EMP9999... EMP(maxLng); however, the actual value stored is 1, 2, 3, ... 9998, 9999 ... MaxLng. Of course, when you click in the field, the EMP0001 becomes 0001; however, that may not be enough of a clue to for the unwary as to the true nature of the stored data. Thus, the unwary may attempt a query on [ID]="EMP0001" resulting in a data type mismatch error, when they should be building the query as [ID]=1. (Or in VBA, this will create the same error if one is trying to build on the perceived "String" when in fact the field value is the numeric portion only)

Jforb's link is certainly one option and is along the same lines I've used in the past. I would take his suggestion one step further by inserting a new field into the data table, if needed, set the indexed to "Yes No Duplicates" to store your new customer id then revert your primary key back to the numeric only.
Oct 27 '15 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Ron Brennan | last post by:
Good morning. I have a page displayed and want to get information from a user using showModalDialog, and then send a request to the server for more information based on the user info from the...
16
by: StenKoll | last post by:
Help needed in order to create a register of stocks in a company. In accordance with local laws I need to give each individual share a number. I have accomplished this by establishing three tables...
17
by: Alan Carter | last post by:
http://www.mvps.org/access/tencommandments.htm Thou shalt not use Autonumber if the field is meant to have meaning for thy users. Why? Alan
2
by: S P Arif Sahari Wibowo | last post by:
Hi! Do you know how to put a form's Access-Visual-Basic-code that will force the form to be inserted, while the user has not type anything in the form, without changing focus, selection, etc.? ...
6
by: David Gartrell | last post by:
Hi i'm trying to import an Excel Spreadsheet into Access2000 but the data types for two of the fields in my imported table are being identified incorrectly. Is there a way of using some VB code in...
2
by: gaffar | last post by:
Hello Sir, How to assign more than one primary key to table by this below following code. i am able assign to a single field only. how to assign primary key to more than one field. the primary key...
2
by: Yeah | last post by:
I have a simple fill-out form with three fields, in this order: Name, E-mail, and Comment. But when I receive the E-mail containing the form data, the fields are listed backwards (Comment, E-mail,...
5
by: John Smith | last post by:
I have tables that I want to fire either an update or insert trigger on. I could write a script containing a long list of inserts but I'm looking for something simpler. Would isql work? Any...
13
by: Jennytranxxx | last post by:
I am creating a timesheet system for my company and its got a pretty simple layout at the minute. I am multiplying the staff charge out rate to the hours they have worked on a job. Every now and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.