Hi All,
I am writing a program in C, which will be driving via a MS Access database.
I am relitivly new to database design, so if anyone could help me with my
issue I would be greatful.
I have defined a database field to be a primary Key, this field is set to
contain the AutoNumber data type.
I would like to know if it is possible to start the autonumber sequence from
a number other than 0.
Thanks 2 1749
See:
Set AutoNumbers to start from ...
at: http://allenbrowne.com/ser-26.html
You can also set the Seed of the Autoincrement column using ADOX if you use
a JET 4 database format.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Materialis ed" <ma**********@p rivacy.net> wrote in message
news:3v******** *****@individua l.net... I am writing a program in C, which will be driving via a MS Access database. I am relitivly new to database design, so if anyone could help me with my issue I would be greatful. I have defined a database field to be a primary Key, this field is set to contain the AutoNumber data type. I would like to know if it is possible to start the autonumber sequence from a number other than 0.
This SQL will alter your column assuming the column meets the
requirements for autonumber and you are using JET 4.0.
"ALTER TABLE Table1 ALTER COLUMN ID Identity (200,10)"
Notes:
(200, 10) -> seed:200; increment:10
1. You must run the SQL from an OLEDB interface (ADO is a common OLEDB
interface; in Access one can use
Application.Cur rentProject.Con nection.Execute ; DBengine and CurrentBD
are not part of an OLEDB interface);
2. If the table already has records numbered 1,2,3,4 etc, their
autonumber will not be changed (even if you remove the autonumber
column and start over);
3. the next record appended will have an autonumber of 200; if there
already is an autonumber of 200 then the append will fail (assuming a
primary key or not allow duplicates index). This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Lee C. |
last post by:
I'm finding this to be extremely difficult to set up. I understand
that Access won't manage the primary key and the cascade updates for a
table. Fine. I tried changing the PK type to number and setting
default value to a UDF that manages the auto-numbering. Access won't
take a UDF as a default value. Okay, I'll use SQL WITHOUT any
aggregate functions, for the default value. Access won't do that
either. Okay, I create a second...
|
by: BT Openworld |
last post by:
I've just had to upgrade to Access 2003. Our company's main sales database
started in Access V1.0 and has progressed through V2.0 and 97 without
problems. I've converted it to 2003 format and have been going through a
process of testing it. To my horror I noticed that seemingly without
provocation, it has started re-using old Autonumber values. For example, I
have an archive routine which removes completed sales enquiry records out of
the...
|
by: Traci |
last post by:
If I have a table with an autonumber primary key and 100 records and I delete
the last 50 records, the next record added would have a primary key of 101. Is
there any way to have the primary key start at 51 after the last 50 records are
deleted?
Thanks!
Traci
|
by: larry |
last post by:
Hi there
The table in question now has around 25000 records (simple -only 3
columns)
Records are added with a simple insert statement :
INSERT INTO SS_REQUEST_SERVICES ( REQUEST_ID, SERVICE_ID ) values(?,?)
and the autonumber field is incrementet with one. No problem ; - all
|
by: jimfortune |
last post by:
Sometimes I use Autonumber fields for ID fields. Furthermore,
sometimes I use those same fields in orderdetail type tables. So it's
important in that case that once an autonumber key value is assigned to
a record that it doesn't change. Occasionally I find that due to
corruption or an accidental deletion and restore of a record from a
backup the autonumber field needs to be tidied up. So when I create
(through AddNew) the autonumber...
| |
by: petebeatty |
last post by:
I have created a SQL string the properly inserts a record in the table.
However, the insert does not occur at the end of the table. Instead
it inserts a record after the last record that I viewed. This would be
OK, except it assigns a autonumber to be one greater than the last
viewed record. This causes a duplicate autonumber. I know I can
change the autonumber index (Primary Key) to not allow duplicates.
How can I force the insert...
|
by: Alan Mailer |
last post by:
A project I'm working on is going to use VB6 as a front end. The back
end is going to be pre-existing MS Access 2002 database tables which
already have records in them *but do not have any AutoNumber* fields
in them.
Correct me if I'm wrong, but I'm assuming this means that I cannot now
alter these existing Access tables and change their primary key to an
"AutoNumber" type.
If I'm right about this, I need some suggestions as to the...
|
by: Macbane |
last post by:
Hi All,
Hope someone can help me with this. I have some PDA database software
which sync with tables in an access database on my computer. It works
fine until you want to sync tables that contain autonumber. Basically
it won't allow you to sync autonumber fields because if you tried to
change the autonumber on your PDA database access will not accept this
on syncing. I don't want to change the autonumber so that is not an
issue but...
|
by: Tom_F |
last post by:
To comp.databases.ms-access --
I just discovered, to my more than mild dismay, that some tables in my
Microsoft Access 2003 database have duplicate numbers in the
"AutoNumber" field. (Field Size is set to "Long Integer", and New
Values is set to "Increment".) I know that an old version of the Jet
database engine can cause this problem, but my version of msjet40.dll
is 4.0.8618.0, which is supposedly bug-free in this respect. I am...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |