Solved

How to solve runtime error '2147352567(80020009)'

Posted on 2011-03-25
11
2,102 Views
Last Modified: 2013-11-27
I get this error when I try to change a control on a form and the control is a primary key in the underlying table.
0
Comment
Question by:SowleMan
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 75
ID: 35217743
If the PK is an Access AutoNumber (?), then it cannot be changed.

mx
0
 

Author Comment

by:SowleMan
ID: 35219055
Thanks, DatabaseMX.  

I really don't want to change the key.  I want to replace the key with another, valid PK.  For example, I want to modify a transaction record so it points to The Home Depot, instead of  Lowes.

Sowleman
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35222221
Then something seems awry in your design...

For example: If you are a shipper and you want to change the ship destination from Home Depot, to Lowes.

The you have a "Stores" table:

tblStores
StoreID (Primary Key)
StoreName
...ect

..Then you have a shipments table

tblShipments
ShipmentID (Primary Key)
StoreID (Foreign Key)
ShipmentDate
...etc

These two tables are linked in the relationships window on "StoreID", and Referential Integrity is enforced.

In this case, it is quite easy to change the StoreID in the shipments table to another StoreID, without issue.

So you will have to explain to us the design and relationships between your tables.
Also provide us with the details of how and where, exactly, you are trying to change the ID.


JeffCoachman

0
 
LVL 75
ID: 35222388
Guess I'm not quite following.  Maybe Jeff has explained what you are after?

mx
0
 
LVL 31

Expert Comment

by:Helen_Feddema
ID: 35222504
Changing a value in a key field might result in a violation of normalization.  We need more information on what you are trying to do, in terms of tables, fields and relationships.
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:SowleMan
ID: 35222626
Thanks - I really appreciate your interest in my problem.
Jeff described my situation well.  I have a tblStores with fields StoreID (primaryKey, auto-number) and StoreName.  tblShipments contains a foreign key (also called StoreID) in order to retrieve StoreName via an ACCESS relationship.  I expect the relationship to maintain referential integrity.

In my system, I use a query to retrieve fields  from tblStores and tblShipments, and that query is the recordsource for my form. I sometimes detect an improper StoreName. Example: a tblShipments record shows Home Depot and I want to change it to Lowes.  Using VBA, I retrieve from tblStores the Lowes StoreID and I want to assign the Lowes StoreID to tblShipments.StoreID.  ACCESS replies with runtime error  '-2147352567(80020009)', "To make changes to this field, you must first save the record".

The actual VBA that causes the error: me.StoreID = longStoreID.  I am trying to make this change by assigning the correct StoreID to the foreign key (displayed but not enabled) in the form.

I am learning this stuff as a retirement hobby, so my education is weak in many areas.  30 years ago I programmed in COBOL.

Steve
0
 

Author Comment

by:SowleMan
ID: 35222674
Helen/ MX/ Jeff -  Could it be that I have to delete the inaccurate record and then add a new, correct record?  If am comfortable with DAO, but is there a way to manipulate the data in the underlying query without messing up the flow of the form?

Steve
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35223805
Unless you also assigned StoreID in the shipments table as Primary key, I can't see what the problem might be...

You did not say by what method you are assigning longStoreID, but in a global sense you may want to use a combobox.

Here is a very simple sample, there are no problems with changing the store.

JeffCoachman


db344.mdb
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35223815
ooops, ...here is the sample
db344.mdb
0
 

Accepted Solution

by:
SowleMan earned 0 total points
ID: 35363794
DatabaseMX -

If I cannot change a field that is a Primary Key, then the solution is to delete the child row and then re-add a replacement child row with new info (allowing ACCES to provide a new PK) ?

Thanks.
0
 

Author Closing Comment

by:SowleMan
ID: 35446447
I did not get a workable answer.  I want to close it so I casn move on
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

707 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

12 Experts available now in Live!

Get 1:1 Help Now