473,756 Members | 8,034 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Table w/ Autonumber AND Cascade update

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 column, make it autonumber and PK,
then set the default value of my old PK column to the field value of
the new autonumber PK field. Wow! Access won't do that either. Am I
crazy or should this be easier? Any insight will be greatly
appreciated.

MS Access 2002
Windows XP Pro

Thanks,
Lee
Nov 12 '05 #1
33 4303
On 7 Feb 2004 14:55:45 -0800, Lee C. wrote:
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 column, make it autonumber and PK,
then set the default value of my old PK column to the field value of
the new autonumber PK field. Wow! Access won't do that either. Am I
crazy or should this be easier? Any insight will be greatly
appreciated.

MS Access 2002
Windows XP Pro

Thanks,
Lee


What is it you are trying to do?
Autonumbers are not meant to be "managed". They're a one time use, unique
value that can be automatically assigned without fear of it being repeated.
Access manages cascade updates just fine. If a record is changed, it's
related record will be adjusted as long as the relationships are set, and
the new values do not violate the rules that have been defined.

If you are trying to use a numbering system that never breaks sequence,
then you'll need to create update queries or a function that renumbers the
desired records. If relationships are defined, then these changes will
cascade.
--
Mike Storr
veraccess.com
Nov 12 '05 #2
What I am trying to do is have the capability of changing a record's
primary key value and have it cascade updated throughout related
tables.

Autonumbers certainly are managed. Access assigns them and ensures
they are unique. That is management, my friend. <g>

I know Access manages cascade updates just fine--but it refuses to
take on the management task if the PK is an autonumber! Yeah, yeah,
you can't change an autonumber. <g> That's what I am trying to work
around. (If someone paid me, I could write an RDBMS where you could
change an autonumber, and I'd still ensure uniqueness. Access already
lets me change any other PK--that's not autonumber--and Access still
ensures uniqueness, or prevents the change. Why is autonumber so
different? Because Microsoft chose to have it that way; not because
it's impossible or bad design.)

This is an existing database, which I didn't design: Requisitions have
line items. Line items can be reassigned to other requisitions. All
I want is to be able to change the ReqID (currently an autonumber) of
an existing line item and have Access cascade update the related
tables.

This really doesn't seem like to much to ask from a version 10 RDBMS.
Presently, the line item is copied to a temp table, and then VBA is
used to delete the record from tblLineItems, then VBA copies the rec
from the temp table back to tblLineItems with the new ReqID, and
deletes the rec from the temp table. There are so many related tables
that this nightmare is cumbersome to manage in VBA. Hence, my idea to
have the Relation Database MANAGEMENT System do some managing.

Thanks again,
Lee

Mike Storr <st******@sympa tico.ca> wrote in message news:<1w******* *************** ********@40tude .net>...

What is it you are trying to do?
Autonumbers are not meant to be "managed". They're a one time use, unique
value that can be automatically assigned without fear of it being repeated.
Access manages cascade updates just fine. If a record is changed, it's
related record will be adjusted as long as the relationships are set, and
the new values do not violate the rules that have been defined.

If you are trying to use a numbering system that never breaks sequence,
then you'll need to create update queries or a function that renumbers the
desired records. If relationships are defined, then these changes will
cascade. On 7 Feb 2004 14:55:45 -0800, Lee C. wrote:
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 column, make it autonumber and PK,
then set the default value of my old PK column to the field value of
the new autonumber PK field. Wow! Access won't do that either. Am I
crazy or should this be easier? Any insight will be greatly
appreciated.

MS Access 2002
Windows XP Pro

Thanks,
Lee

Nov 12 '05 #3
I don't believe any RDMS that has the equivalent of AutoNumbers (say, for
instance, SQL Server's Identity type) allows you to change the value of the
field. There is no legitimate reason I can think of why you'd need to.

As Mike alludes to, AutoNumbers are intended for one purpose: to create an
(almost guaranteed) unique value that can be used as a primary key. Seldom,
if ever, should the value of the AutoNumber field even be shown to the user.
If you care about the value of the AutoNumber field, then it's almost
certain that you should be using a different data type.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(No private e-mails, please)

"Lee C." <ci***********@ hotmail.com> wrote in message
news:c4******** *************** **@posting.goog le.com...
What I am trying to do is have the capability of changing a record's
primary key value and have it cascade updated throughout related
tables.

Autonumbers certainly are managed. Access assigns them and ensures
they are unique. That is management, my friend. <g>

I know Access manages cascade updates just fine--but it refuses to
take on the management task if the PK is an autonumber! Yeah, yeah,
you can't change an autonumber. <g> That's what I am trying to work
around. (If someone paid me, I could write an RDBMS where you could
change an autonumber, and I'd still ensure uniqueness. Access already
lets me change any other PK--that's not autonumber--and Access still
ensures uniqueness, or prevents the change. Why is autonumber so
different? Because Microsoft chose to have it that way; not because
it's impossible or bad design.)

This is an existing database, which I didn't design: Requisitions have
line items. Line items can be reassigned to other requisitions. All
I want is to be able to change the ReqID (currently an autonumber) of
an existing line item and have Access cascade update the related
tables.

This really doesn't seem like to much to ask from a version 10 RDBMS.
Presently, the line item is copied to a temp table, and then VBA is
used to delete the record from tblLineItems, then VBA copies the rec
from the temp table back to tblLineItems with the new ReqID, and
deletes the rec from the temp table. There are so many related tables
that this nightmare is cumbersome to manage in VBA. Hence, my idea to
have the Relation Database MANAGEMENT System do some managing.

Thanks again,
Lee

Mike Storr <st******@sympa tico.ca> wrote in message

news:<1w******* *************** ********@40tude .net>...

What is it you are trying to do?
Autonumbers are not meant to be "managed". They're a one time use, unique value that can be automatically assigned without fear of it being repeated. Access manages cascade updates just fine. If a record is changed, it's
related record will be adjusted as long as the relationships are set, and the new values do not violate the rules that have been defined.

If you are trying to use a numbering system that never breaks sequence,
then you'll need to create update queries or a function that renumbers the desired records. If relationships are defined, then these changes will
cascade.

Nov 12 '05 #4
I appreciate the replies. I'm not looking to redesign Accesss. I'm trying
to work around it's limitations--I'll concede that they are wonderful
product features, if it will get us back on track.. <g> That is what I
want help with, the workaround. We can all agree or disagree on how things
should be, but that doesn't help me right now. How do I get around this, is
my question.

I am stuck with a table that has an autonumber PK, because it has no good
candidate key fields or field combinations. I need to convert it to a
number so that I can change the field value when necessary. Once I do
change the field type, how do I manage the PK field values for new records
if Access won't let me: (1) use SQL in the default value, (2) use a UDF in
the default value, or (3) reference another field in the default value?

I abhor the idea of doing this in the front-end mdb.

Sincere thanks,
Lee
"Douglas J. Steele" <NOSPAM_djsteel e@NOSPAM_canada .com> wrote in message
news:XX******** **********@twis ter01.bloor.is. net.cable.roger s.com...
I don't believe any RDMS that has the equivalent of AutoNumbers (say, for
instance, SQL Server's Identity type) allows you to change the value of the field. There is no legitimate reason I can think of why you'd need to.

As Mike alludes to, AutoNumbers are intended for one purpose: to create an
(almost guaranteed) unique value that can be used as a primary key. Seldom, if ever, should the value of the AutoNumber field even be shown to the user. If you care about the value of the AutoNumber field, then it's almost
certain that you should be using a different data type.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(No private e-mails, please)

"Lee C." <ci***********@ hotmail.com> wrote in message
news:c4******** *************** **@posting.goog le.com...
What I am trying to do is have the capability of changing a record's
primary key value and have it cascade updated throughout related
tables.

Autonumbers certainly are managed. Access assigns them and ensures
they are unique. That is management, my friend. <g>

I know Access manages cascade updates just fine--but it refuses to
take on the management task if the PK is an autonumber! Yeah, yeah,
you can't change an autonumber. <g> That's what I am trying to work
around. (If someone paid me, I could write an RDBMS where you could
change an autonumber, and I'd still ensure uniqueness. Access already
lets me change any other PK--that's not autonumber--and Access still
ensures uniqueness, or prevents the change. Why is autonumber so
different? Because Microsoft chose to have it that way; not because
it's impossible or bad design.)

This is an existing database, which I didn't design: Requisitions have
line items. Line items can be reassigned to other requisitions. All
I want is to be able to change the ReqID (currently an autonumber) of
an existing line item and have Access cascade update the related
tables.

This really doesn't seem like to much to ask from a version 10 RDBMS.
Presently, the line item is copied to a temp table, and then VBA is
used to delete the record from tblLineItems, then VBA copies the rec
from the temp table back to tblLineItems with the new ReqID, and
deletes the rec from the temp table. There are so many related tables
that this nightmare is cumbersome to manage in VBA. Hence, my idea to
have the Relation Database MANAGEMENT System do some managing.

Thanks again,
Lee

Mike Storr <st******@sympa tico.ca> wrote in message

news:<1w******* *************** ********@40tude .net>...

What is it you are trying to do?
Autonumbers are not meant to be "managed". They're a one time use, unique value that can be automatically assigned without fear of it being repeated. Access manages cascade updates just fine. If a record is changed, it's
related record will be adjusted as long as the relationships are set, and the new values do not violate the rules that have been defined.

If you are trying to use a numbering system that never breaks sequence, then you'll need to create update queries or a function that renumbers the desired records. If relationships are defined, then these changes will
cascade.


Nov 12 '05 #5
Lee Cichanowicz wrote:
I appreciate the replies. I'm not looking to redesign Accesss. I'm trying
to work around it's limitations--I'll concede that they are wonderful
product features, if it will get us back on track.. <g> That is what I
want help with, the workaround. We can all agree or disagree on how things
should be, but that doesn't help me right now. How do I get around this, is
my question.

I am stuck with a table that has an autonumber PK, because it has no good
candidate key fields or field combinations. I need to convert it to a
number so that I can change the field value when necessary. Once I do
change the field type, how do I manage the PK field values for new records
if Access won't let me: (1) use SQL in the default value, (2) use a UDF in
the default value, or (3) reference another field in the default value?

I abhor the idea of doing this in the front-end mdb.


You definately have a no-go there. There are no user defined triggers in
Access (Jet engine). So, nothing inbetween numbers and autonumber.

As long as your users do not touch the tables, is there a real objection
to handling new numbers from the front end?
--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Nov 12 '05 #6
You have clearly identified problem, Bas: No triggers in Access! What a
tremendous shortcoming...I mean, product feature, that is.

My real objection to managing record IDs in the front end is that I upsize a
lot of Access databases to SQL Server. I also put Web front-ends on them.
I know that the more back-end management that I do in the front-end, the
greater the nightmare upsizing or Web-enabling becomes. So, it's just a
matter of principle, but it seems I'm screwed here.

Thanks,
Lee

"Bas Cost Budde" <ba*@heuveltop. org> wrote in message
news:c0******** *@news2.solcon. nl...

You definately have a no-go there. There are no user defined triggers in
Access (Jet engine). So, nothing inbetween numbers and autonumber.

As long as your users do not touch the tables, is there a real objection
to handling new numbers from the front end?
--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl
Lee Cichanowicz wrote:
I appreciate the replies. I'm not looking to redesign Accesss. I'm trying to work around it's limitations--I'll concede that they are wonderful
product features, if it will get us back on track.. <g> That is what I
want help with, the workaround. We can all agree or disagree on how things should be, but that doesn't help me right now. How do I get around this, is my question.

I am stuck with a table that has an autonumber PK, because it has no good candidate key fields or field combinations. I need to convert it to a
number so that I can change the field value when necessary. Once I do
change the field type, how do I manage the PK field values for new records if Access won't let me: (1) use SQL in the default value, (2) use a UDF in the default value, or (3) reference another field in the default value?

I abhor the idea of doing this in the front-end mdb.

Nov 12 '05 #7
ci***********@h otmail.com (Lee C.) wrote:
What I am trying to do is have the capability of changing a record's
primary key value and have it cascade updated throughout related
tables.
But why?
This is an existing database, which I didn't design: Requisitions have
line items. Line items can be reassigned to other requisitions. All
I want is to be able to change the ReqID (currently an autonumber) of
an existing line item and have Access cascade update the related
tables.
But this sounds like ReqID is a foreign key and not the primary key. Surely the
ReqID is a primary key in the Requesition Header table. But it would be a foreign
key in the Line Item table.
This really doesn't seem like to much to ask from a version 10 RDBMS.
Presently, the line item is copied to a temp table, and then VBA is
used to delete the record from tblLineItems, then VBA copies the rec
from the temp table back to tblLineItems with the new ReqID, and
deletes the rec from the temp table. There are so many related tables
that this nightmare is cumbersome to manage in VBA. Hence, my idea to
have the Relation Database MANAGEMENT System do some managing.


Just curious. What kind of related tables do you have from the Line Items table?

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Nov 12 '05 #8
> >What I am trying to do is have the capability of changing a record's
primary key value and have it cascade updated throughout related
tables.
But why?


As it says below: Line items can be reassigned to other requisitions. All
I want is to be able to change the ReqID (currently an autonumber) of
an existing line item and have Access cascade update the related
tables.
This is an existing database, which I didn't design: Requisitions have
line items. Line items can be reassigned to other requisitions. All
I want is to be able to change the ReqID (currently an autonumber) of
an existing line item and have Access cascade update the related
tables. But this sounds like ReqID is a foreign key and not the primary key. Surely the ReqID is a primary key in the Requesition Header table. But it would be a foreign key in the Line Item table.


Yep. Precisely.
This really doesn't seem like to much to ask from a version 10 RDBMS.
Presently, the line item is copied to a temp table, and then VBA is
used to delete the record from tblLineItems, then VBA copies the rec
from the temp table back to tblLineItems with the new ReqID, and
deletes the rec from the temp table. There are so many related tables
that this nightmare is cumbersome to manage in VBA. Hence, my idea to
have the Relation Database MANAGEMENT System do some managing.


Just curious. What kind of related tables do you have from the Line Items

table?

tblRequisitions --> tblLineItems --> tblLineItemFund ing -->
tblUnitAcceptan ce ...
Nov 12 '05 #9
On 7 Feb 2004 14:55:45 -0800, Lee C. wrote:
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 column, make it autonumber and PK,
then set the default value of my old PK column to the field value of
the new autonumber PK field. Wow! Access won't do that either. Am I
crazy or should this be easier? Any insight will be greatly
appreciated.

MS Access 2002
Windows XP Pro

Thanks,
Lee


I think the only work around for this is to change the data type on the
field from AutoNumber to Long. You'll need to create you own function to
generate new numbers, but your update queries should then be capable of
changing your IDs

--
Mike Storr
veraccess.com
Nov 12 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2768
by: Ed_No_Spam_Please_Weber | last post by:
Hello All & Thanks in advance for your help! Background: 1) tblT_Documents is the primary parent transaction table that has 10 fields and about 250,000 rows 2) There are 9 child tables with each having 3 fields each, their own PK; the FK back to the parent table; and the unique data for that table. There is a one to many relation between the parent and each of the 9 child rows. Each child table has between 100,000 and 300,000
14
4299
by: serge | last post by:
I have a scenario where two tables are in a One-to-Many relationship and I need to move the data from the Many table to the One table so that it becomes a One-to-One relationship. I need to salvage the records from the many table and without going into detail, one of the reasons I can't do the opposite as there are records in the ONE table that I need to keep even if they don't have any child records in the MANY table. Below I created...
1
2696
by: Jon Earle | last post by:
Hi, Had a problem with PsotgreSQL v7.3.4. I had a table that, after a while, decided to give me a fit: db=> insert into blocklist values ('2', 'km4n7s28ehiFizeYupm93Q', '1','2','3'); ERROR: Index idx_blk_id_addr is not a btree When I deleted and recreated the table, it worked fine. Any ideas?
5
3542
by: PAUL | last post by:
Hello, I have 2 tables with a relationship set up in the dataset with vb ..net. I add a new record to the parent table then edit an existing child record to have the new parent ID. However when I do the update the changed parentid in the child table fails to change. No error is given its just that the change is not written to the Database. When I step through the records for the child table the one I would expect to be changed has a row...
1
4587
by: Robert Fitzpatrick | last post by:
I am running PostgreSQL 7.4.5 and have a trigger on a table called tblriskassessors which inserts, updates or delete a corresponding record in tblinspectors by lookup of a contact id and license number match. The INSERT and DELETE work fine. The UPDATE works good unless I update the license number. The error, at the bottom of this message, suggests the primary key violation. But my UPDATE in no way alters the primary key, which is...
11
10152
by: FreeToGolfAndSki | last post by:
Hi, I have an Orders Table that has Employee1 and Employee2 (one is the sales rep the other is the telemarketing rep) Both of these fields need to cascade update against the Employees table. I can't seem to create the desired relationship in a Diagram and I'm not sure how best to set this up. Any ideas? Thanks in advance...
6
3858
by: polocar | last post by:
Hi, I'm writing a program in Visual C# 2005 Professional Edition. This program connects to a SQL Server 2005 database called "Generations" (in which there is only one table, called "Generations"), and it allows the user to add, edit and delete the various records of the table. "Generations" table has the following fields: "IDPerson", NamePerson", "AgePerson" and "IDParent". A record contains the information about a person (his name, his...
1
4063
by: adithi | last post by:
My Table Structure is: Table A Table B Table C colA -PK Col B-PK Col C-PK Col B-FK Col B-FK Col C-FK This relation establish a Concurrent relation where in Cascade Property fails.I can set Cascade property for any two tabnles...but not the third table. My requirement is :
2
1800
klarae99
by: klarae99 | last post by:
Hello, I am working in Access 2003 to create a database to record information about an annual fundraiser. I was hoping someone could review my table structure and make sure that it is normalized correctly and that it is set up to do what I would like it to do. I have some doubts on my current table structure and I would really appreciate any suggestions for improvement before I move on to creating my data entery forms. The purpose of...
0
9456
marktang
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...
0
9275
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,...
0
9873
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9846
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
tracyyun
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...
0
8713
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3806
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
3
2666
bsmnconsultancy
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...

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.