Solved

How to solve runtime error '2147352567(80020009)'

Posted on 2011-03-25
11
2,458 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

729 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