Add records

F

Florin

hi,

how can I add new record in a table (through a text box in a form), bat I
want verifyed for duplicated in a one field

thanks
 
W

Wayne-I-M

Hi Florin

You can index the 1st name and surname in the table - but this is a problem
if there are 2 people with the same 1st and 2nd name (there are a lot of John
Smith's in England). So you could add postcode to the index (but they may
have moved) etc, etc.

You are better doing it on your form.

I assume you have a table called "tblSomeDetails", there is an field call
"PersonsID"
with 2 fields called "1stName" and "Surname", of course change the names to
what they really are.

Next, create a form (don't change the field names) and use this on the
AfterUpdate event of the control called Surname.


Private Sub Surname_AfterUpdate()
If ((DLookup("[PersonsID]", "[tblSomeDetails]", "[1stName] ='" &
Form!1stName & "' AND [Surname] = '" & Form!Surname & "'"))) Then
Beep
MsgBox "This person may have a record", vbOKOnly, "Some Box Title"
End If
End Sub



This will warn a user if this person "may" have a record already (after you
have inserted the 1st name and surname). They may simply be called the same
so you will still be able to add the record after checking the details.

Hope this helps

End Sub
 
F

Florin

Hi, Wayne-I-M

Thanks for your sugestion

I have a big problem because my table is linked (.dbf) and don't have a
index field!
I have a table "Comenzi" with an field call "NrCom" who are verifyed and
will warn user if record already exist.

thanks

florin
Bucharest, Romania




Wayne-I-M said:
Hi Florin

You can index the 1st name and surname in the table - but this is a problem
if there are 2 people with the same 1st and 2nd name (there are a lot of John
Smith's in England). So you could add postcode to the index (but they may
have moved) etc, etc.

You are better doing it on your form.

I assume you have a table called "tblSomeDetails", there is an field call
"PersonsID"
with 2 fields called "1stName" and "Surname", of course change the names to
what they really are.

Next, create a form (don't change the field names) and use this on the
AfterUpdate event of the control called Surname.


Private Sub Surname_AfterUpdate()
If ((DLookup("[PersonsID]", "[tblSomeDetails]", "[1stName] ='" &
Form!1stName & "' AND [Surname] = '" & Form!Surname & "'"))) Then
Beep
MsgBox "This person may have a record", vbOKOnly, "Some Box Title"
End If
End Sub



This will warn a user if this person "may" have a record already (after you
have inserted the 1st name and surname). They may simply be called the same
so you will still be able to add the record after checking the details.

Hope this helps

End Sub
--
Wayne
Manchester, England.



Florin said:
hi,

how can I add new record in a table (through a text box in a form), bat I
want verifyed for duplicated in a one field

thanks
 
Top