独特的入口 [英] unique entry

查看:70
本文介绍了独特的入口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含年份字段和票号字段的表。两者合起来制作我们的全票号码。所以一个例子是


年场 - " 09-"

ticketnumber字段 - " 0001"
完整的票号将是09-0001


我想知道的是(如果我的条款不正确,我很抱歉)可以链接这两个字段,以便条目必须是唯一的。因为当2010年到来时我们将再次使用0001,所以我不能让ticketnumber字段独一无二。所以我想知道我是否可以在两个领域都有独特的条目...我希望我解释说足够的大声笑...如果有人有任何建议,将不胜感激。谢谢!

i have a table that has a year field and a ticket number field. the two combine to make our full ticket number. so an example would be

year field- "09-"
ticketnumber field- "0001"
the full ticket number would be 09-0001

what i want to know is (and im sorry if my terms are incorrect) can i link the two fields so that the entry has to be unique. because when 2010 comes we are going to use 0001 again so i cant just make the ticketnumber field unique. so i wanted to know if i can have the unique entry look in both fields... i hope im explaining that enough lol... if anyone has any suggestions it would be greatly appreciated. thanks!

推荐答案

为此,您可以创建一个输入字段未绑定的表单。然后,当用户填写并单击按钮时,您可以从文本框中获取值并确保它们有效。您可以通过这样做:


使用DLookup(" AnyField","表名"," YearField ="""&安培; txtBoxYear和放大器;""" ; AND TicketNumberField = QUOT;""&安培; txtBoxTicketNumber&安培;"""")


(假设两个字段是字符串类型,数字删除多余" ;")

如果结果为null,则该组合不在表中,否则至少有一行具有这些值。


如果一切都有效,然后你用文本框中的值插入一个带有DoCmd.RunSQL的新记录。
To do this, you could make a form with your input fields unbound. Then, when the user fills them out and clicks a button, you can grab the values from the text boxes and make sure that they are valid. You could do this by:

DLookUp ("AnyField", "TableName", "YearField = """ & txtBoxYear & """ AND TicketNumberField = """ & txtBoxTicketNumber & """")

(assuming both fields are string types, for numbers remove the extra "")
If the result of that is null, that combination is not in the table, otherwise at least one row has those values.

If everything is valid, then you insert a new record with values from the text boxes with a DoCmd.RunSQL.


我得到了你所说的基础,但是我是新手在访问时,我不太确定如何正确实现这个...你认为你可以为那些正在学习绳索的人打破一点吗?非常感谢!
i got the basis of what you are saying, but being the novice that i am at access, am not quite sure on how to correctly implement this... do you think you can break it down a little more for someone who is just learning the ropes? thanks a lot!


这种方式通过代码完成所有工作,所以我们应该先尝试一个更简单的解决方案。


使用常规表格绑定到数据字段的字段,但设置ticketnumber字段的Validation属性。你应该能够将其设置为:


ISNULL(使用DLookup(QUOT; AnyField","表名"," YearField = QUOT;""&安培; [txtBoxYear] &安培;""" AND TicketNumberField = QUOT;""&安培; [txtBoxTicketNumber]&安培;""""))


。您将需要文本框名称周围的[]。
This way does pretty much everything through code, so we should probably try a simpler solution first.

Use a regular form with the fields bound to your data fields, but set the Validation property of the ticketnumber field. You should be able to set it to:

IsNull(DLookUp ("AnyField", "TableName", "YearField = """ & [txtBoxYear] & """ AND TicketNumberField = """ & [txtBoxTicketNumber] & """"))

You will need the [ ] around the textbox names.


这篇关于独特的入口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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