473,434 Members | 4,626 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,434 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 1242
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.