添加具有使用访问中的自动编号生成的旧ID的记录 [英] Adding records with old ids that were generated using auto number in access

查看:64
本文介绍了添加具有使用访问中的自动编号生成的旧ID的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个访问数据库.在此,我有一个表,该表具有创建ID的自动编号字段.我以某种方式删除了表中的这些ID.现在,我已经删除了这些记录,我需要相同的顺序才能继续(我希望将已删除的ID重新返回到表中),但是由于自动编号功能会永远删除ID,因此我无法执行此操作.我尝试将字段数据类型更改为仅数字并手动输入ID,但不会更改,因为数据库警告我说它与其他功能有关,因此我需要先删除它们,这与关系有关.请帮助我找出一种获取表中旧ID的方法.数据库非常复杂,它不仅有一个表,而且还有许多表格和报告,而且它们都相互交织在一起.帮助!

I have an access database. In this I have a table which had an auto number field that created the ids. I somehow deleted these ids in the table. Now that I have deleted these records, I need a same sequence to continue (I want the deleted ids back in the table), but I am not able to do so because the auto number feature deleted the ids forever. I tried changing the field datatype to just number and entering the ids manually, but it won't change because the database gives me a warning saying that it is related to other features and I need to delete them first, something to do with relations. Please help me figure out a way to get the old ids in the table. The database is pretty complex, it doesn't just have one table, it has a lot of forms and reports and they are all intertwined. HELP!

推荐答案

Access将允许您执行INSERT语句,该语句添加带有未使用自动编号值的行.

Access will allow you to execute an INSERT statement which adds a row with an unused autonumber value.

INSERT INTO MyTable (auto_num_field, text_field)
VALUES (27, 'foo');

但是,如果Access对象由于已定义的关系,则需要首先删除该关系,添加数据,执行满足关系约束所需的其他所有操作,最后重新创建该关系.

However if Access objects due to a defined relationship, you need to first drop the relationship, add the data, do whatever else is needed to satisfy the relationship constraint, and finally re-create the relationship.

OTOH,如果您已经将字段的数据类型从自动编号更改为其他类型,并且没有该表的备份副本,这可能会更具挑战性.我们需要更多信息来找到解决方案.

OTOH, if you've already changed the field's data type from autonumber to something else, and you don't have a backup copy of the table, this could be even more challenging. We'd need more information to figure out a solution.

这篇关于添加具有使用访问中的自动编号生成的旧ID的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆