Solved

How to solve runtime error '2147352567(80020009)'

Posted on 2011-03-25
11
2,386 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
Revamp Your Training Process

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

 
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
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.
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

739 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