停止表上的重复记录?

问题描述:

大家好(正如尼克博士所说),


我在停止桌面上的重复记录时遇到问题。我所拥有的是一个表格,您可以在一个人的日子里申请。我想要做的就是这样做,如果你输入一个人名和日期,它会在桌子上查看,看看该记录是否已经存在。如果确实如此,则会显示一条错误消息,说明该记录存在,如果没有则只保存记录。


我试图做的是设置表格以便人员姓名和关闭日期,是主键,这样它就不会让你保存重复的记录。它工作正常一段时间,但现在我不断收到错误消息:2105。任何人都可以帮我设置一个可能更好地处理这个而不是使用主键选项的VBA代码吗?


感谢您的帮助!

Hi everybody (as Dr. Nick would say),

I am having a problem stopping duplicate records on my table. What I have is a form where you can enter in a persons day off request. What im trying to do is make it so if you enter in a persons name and date it will look on the table and see if that record already exisits. If it does then show an error message saying this record exisits if not then just save the record.

What I tried to do was set up the table so that the name of the person and the date off, were the Primary keys so that way it would not let you save a duplicate record. It was working ok for a little while but now i keep getting the error message:2105. Can anyone help me out setting up a VBA code that might work better to handle this instead of using the Primary Key option??

Thanks for the help!

是否有必须输入除了主键之外你留下的空白字段?检查表中的字段属性。


如果您仍然有错误,请尝试避免这样的错误消息:
Is there any "must enter" field you leave in blank other than primary keys? check the field properties in the table.

If you''re still having the error, try avoid the error message like this:
展开 | 选择 | Wrap | 行号


这有点不清楚。


你说你有错误信息2105.我会把它挖出来因为那只是一个数字。
你不能去指定的记录。您可能在记录集的末尾。

您的版本可能有更多相关信息,如表名等。


它听起来我们需要看到导致它确定实际发生的代码。


就索引而言,主密钥不需要排除重复。那将是任何独特的钥匙。你是这个意思吗?无论如何,我建议你设置一个独特的密钥,无论你是否想要依靠设施保护你免受重复。


你所描述的逻辑应该有效。如果它不起作用,那么我希望代码没有正确实现逻辑。同样,我们需要看到代码能够在这里正确帮助。
This is all a little unclear.

You say you have an error message 2105. I''ll dig that up for you as that''s just a number.
You can''t go to the specified record. You may be at the end of a recordset.
Your version may have had more info associated, like table name or such.

It sounds like we would need to see the code that is causing this to determine what is actually happening.

As far as indexing goes, a Primary Key is not required to preclude duplicates. That would be any unique key. Is this what you mean? I would suggest setting up a unique key anyway, regardless of whether or not you want to rely on the facility to protect you from duplicates.

The logic you''ve described should work. If it''s not working then I expect the code is not correctly implementing the logic. Again, we need to see the code to be able to help here properly.


如前所述NeoPa,唯一(不允许重复),名称]和[日期关闭]字段中的>综合索引将在表级解决您的问题。
As previously indicated by NeoPa, a Unique (No Duplicates allowed), Composite Index on the [Name] and [Date Off] Fields would solve your problem at the Table Level.