If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Prevent duplicate from 3 text
Dear All
I have a form contais 3 text name, father_name,Sur_name how can i prevent the duplicate if a user entered John smith george and in another record he enterd the same name John smith george i want to display a msgbox to tell him that the name is duplicated best wishes -- Message posted via http://www.accessmonster.com |
#2
|
|||
|
|||
Prevent duplicate from 3 text
On Thu, 08 Apr 2010 05:33:36 GMT, "ashraf_al_ani via AccessMonster.com"
u54845@uwe wrote: Dear All I have a form contais 3 text name, father_name,Sur_name how can i prevent the duplicate if a user entered John smith george Why should you prevent such an entry? My name is John Vinson. (John Wilmot) My father's name was John Vinson. (John Walker Jr.) His father's name was John Vinson. (John Walker Sr.) Names are not unique; duplicate names are *perfectly legitimate* entries and your program should not prohibit them. I once worked with Dr. Lawrence David Wise and his colleague, Dr. Lawrence David Wise. and in another record he enterd the same name John smith george i want to display a msgbox to tell him that the name is duplicated If you want just a warning (not a prevention) you can use the form's BeforeUpdate event with code like: Private Sub Form_BeforeUpdate(Cancel as Integer) Dim iAns As Integer If Not IsNull(DLookUp("somefield", "yourtable", _ "[Name] = """ & Me![Name] & """ AND Father_Name = """ _ & Me![Father_Name] & """ AND Sur_Name = """ _ & Me![Sur_Name] & """") Then iAns = MsgBox("This name already exists; add it anyway?", vbYesNo) If iAns = vbNo Then Cancel = True ' cancel the addition to the table Me.Undo ' erase the user's input End If End If End Sub -- John W. Vinson [MVP] |
#3
|
|||
|
|||
Prevent duplicate from 3 text
John W. Vinson wrote:
Dear All I have a form contais 3 text [quoted text clipped - 3 lines] John smith george Why should you prevent such an entry? My name is John Vinson. (John Wilmot) My father's name was John Vinson. (John Walker Jr.) His father's name was John Vinson. (John Walker Sr.) Names are not unique; duplicate names are *perfectly legitimate* entries and your program should not prohibit them. I once worked with Dr. Lawrence David Wise and his colleague, Dr. Lawrence David Wise. and in another record he enterd the same name John smith george i want to display a msgbox to tell him that the name is duplicated If you want just a warning (not a prevention) you can use the form's BeforeUpdate event with code like: Private Sub Form_BeforeUpdate(Cancel as Integer) Dim iAns As Integer If Not IsNull(DLookUp("somefield", "yourtable", _ "[Name] = """ & Me![Name] & """ AND Father_Name = """ _ & Me![Father_Name] & """ AND Sur_Name = """ _ & Me![Sur_Name] & """") Then iAns = MsgBox("This name already exists; add it anyway?", vbYesNo) If iAns = vbNo Then Cancel = True ' cancel the addition to the table Me.Undo ' erase the user's input End If End If End Sub thank you you solved my problem best regards -- Message posted via http://www.accessmonster.com |
Thread Tools | |
Display Modes | |
|
|