RE: Prevent duplicate record through form.
- From: Klatuu <Klatuu@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 26 Apr 2005 09:09:02 -0700
The first problem is "" is not the same as Null. I think you may want to try
this:
Dlookup returns a Null vaule if it does not find a match.
If IsNull(DLookup("Cert_ID", "Accounts", "[Cert_ID]= " _
& [forms]![Account![Cert_ID]) Then
' It is a new value for this field
MsgBox "Looks Good"
Else: MsgBox"Record Already exists!"
Cancel = True
End If
"Randy" wrote:
> I have seen this question many times, but I cant get it to work. I have a
> tble named "Accounts" with a fld of "Cert_ID". The field "Cert_ID" will
> have some null values, but what ever data is there can not be duplicated.
> This is a text field. The forms name is "Account" and the textbox name is
> "Cert_ID" with the record source of "Cert_ID" I have seen an several
> examples of preventing duplicates such as below but cant get it to work.
> Any help is appreciated...Thanks..Randy
>
> If Not IsNull(DLookup("Cert_ID", "Accounts", _
> "[Cert_ID]=" & "'" &
> Me.Cert_ID & "'")) _
> Then
> MsgBox "Record Already exists!"
> ' Cancel = True
> Else: MsgBox "Looks Good"
> End If
>
>
>
.
- Follow-Ups:
- Re: Prevent duplicate record through form.
- From: Randy
- Re: Prevent duplicate record through form.
- References:
- Prevent duplicate record through form.
- From: Randy
- Prevent duplicate record through form.
- Prev by Date: RE: Feeding Combo Box
- Next by Date: RE: error 3271
- Previous by thread: Prevent duplicate record through form.
- Next by thread: Re: Prevent duplicate record through form.
- Index(es):
Relevant Pages
|