如果重复的FirstName,LastName,MiddleInitial警告用户 [英] Warn user if duplicate FirstName, LastName, MiddleInitial

查看:142
本文介绍了如果重复的FirstName,LastName,MiddleInitial警告用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我是Access的新手,并且绝对没有VBA知识。我已经承担了创建数据库的负担,直到现在我才使用表达式创建者或宏创建者为我的表单添加功能。


我明白这是一个之前讨论过的问题,但我真的无法让上述解决方案与我的表格一起工作,并希望得到一些建议。


我想要在输入重复名称时出现一个消息框。由于我的名字被分解为FirstName LastName和MiddleIntial,因此这很复杂。我希望有一个警告用户的消息框,但不会完全阻止输入。


我试图使用表达式构建器来创建一个可以放在在表格的更新之前,但无济于事,我收到了Invaild数量的论点。试图保存时的通知。


这是我的表达:

= IIf(DCount([ALL]![Last Name])= 0& DCount ([ALL]![First Name])= 0& DCount([ALL]![Middle Intial])= 0,Null,MsgBox(输入重复名称,继续?,1,重复名称等) )))


我知道这不是追求这个的最佳方法,而且我缺乏编写VBA代码的能力限制了我的结果。任何线索都会受到赞赏。

Hello everyone,

I am painfully new to Access and have absolutely no VBA knowledge. I''ve taken on the the burden of creating a database and up until now I''ve only used the expression creator or the macro creator to add functionality to my forms.

I understand this is a problem that was discussed here before but I really haven''t been able to get the aforementioned solutions to work with my form and was hoping to get some suggestions.

I would like to have a message box come up upon entry of a duplicate name. This is complicated due to my names being broken up into FirstName LastName and MiddleIntial. I hope to have a message box that warns users, but does not prevent entry altogether.

I''ve tried to use the expression builder to create an expression that could be placed in the beforeupdate for the form, but to no avail, I receive an "Invaild number of arguments" notice upon trying to save.

Here is my expression:
= IIf( DCount([ALL]![Last Name])=0 & DCount([ALL]![First Name])=0 & DCount([ALL]![Middle Intial])=0, Null, MsgBox("Duplicate name entered, continue?",1, "Duplicate Name")))


I know this isn''t really the optimal method of pursuing this, again my lack of ability to write VBA code has limited my results. Any leads would be appreciated.

推荐答案




我在联系方式的文本框中有以下表达式形式:


= IIf(DCount(" *"," [eqryContactsExtended]",[[Contact ID]<>"& Nz([联系人ID],0)&"和[联系人姓名] =''"&替换(Nz([联系人姓名]),"''","''''")& "''")> 0,可能重复,"


显示可能的重复和可能的重复。如果有一个匹配的名字。


我也是,呃,累了解释它是如何工作的,我写了一会儿,我还在学习自己,所以我需要解构它。我可以告诉你的是,它有效。


您应该只需用联系人表替换:

[eqryContactsExtended]。

[联系人ID]与您的等效主键。

[联系人姓名]是计算查询字段。如果你在两个字段中有你的名字,你可以用两个字段替换它,它们之间有一个&符号([first]& [last])。


祝你好运。如果您需要更多信息,我明天会回来查看。


Jay



P.S.我记得,我从MSO2007的在线模板库中的Contact Management Database模板中获取了这个。可能是个好看的地方。
Hi,

I have the following expression in a text box on my contact details form:

=IIf(DCount("*","[eqryContactsExtended]","[Contact ID]<>" & Nz([Contact ID],0) & " And [Contact Name] = ''" & Replace(Nz([Contact Name]),"''","''''") & "''")>0,"POSSIBLE DUPLICATE","")

It displays "POSSIBLE DUPLICATE" if there''s a matching name.

I''m too, erm, tired to explain how it works, I wrote it a while back and I''m still learning myself, so I''d need to deconstruct it. What I can tell you is, it works.

You should just be able to replace:
[eqryContactsExtended] with your contacts table.
[Contact ID] with your equivalent primary key.
[Contact Name] is a calculated query field. If you have your name in two fields you can replace this with the two fields with an ampersand between them ("[first] & [last]").

Good luck. I''ll check back tomorrow if you need any more info.

Jay


P.S. I just remembered, I took this from the Contact Management Database template from the online template repository for MSO2007. Might be a good place to look.


我刚刚意识到我可能完全错过了你想要达到的目标。


我上面的解决方案不能用来显示MsgBox,它只是在表单上显示文字。


你是否特别需要一个侵入式MsgBox,而不是一个红色的被动文本框字体?如果是这样,如果没有其他人,我明天会回复你的。这是睡觉时间。


请记住,您可以使用字段串联进行比较,例如: [FName]& [MInit]& [LName]。
And I just realised I might have completely missed what you were trying to achieve.

My solution above can''t be used to display a MsgBox, it just displays text on the form.

Do you have a specific need for an intrusive MsgBox as opposed to a passive text box in red font? If so, I''ll get back to you tomorrow if nobody else has. It''s bed time.

Remember you can use a concatenation of fields for comparison purposes, e.g. [FName]&[MInit]&[LName].


我会使用三个控件中每个控件的 AfterUpdate 事件来调用一个公共控件检查的程序。基本上,如果更改了任何值,则应执行检查。


简单的 DLookup() DCount() Criteria 参数设置为对所有三个控件进行过滤,可以为您提供所需的信息。
I''d use the AfterUpdate events of each of the three controls to call a common procedure which does the check. Essentially, if any of the values is changed then the check should be performed.

A simple DLookup() or DCount() with the Criteria parameter set to filter on all three controls should give you what you need.


这篇关于如果重复的FirstName,LastName,MiddleInitial警告用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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