Solved check if value already exists

eshai

Registered User.
Local time
Today, 22:04
Joined
Jul 14, 2015
Messages
195
hi
i have a form for insert students datiles
on the form is failed name "studentid"(text failed) that have index
what i need is when typing a new "id" the code well search if the "id" is already exists

my code

Code:
If IsNull(DLookup("[studentid]", "students", Me.studentid <> 0)) Then
     msgbox = "No Record Found"
Else
   msgbox ="my msg" 
End If
 
Replace the first line with one of the following:

Code:
If Nz(DLookup("studentid", "students"),"") ="" Then
OR use
If DCount("studentid", "students") = 0 Then

EDIT: Oops. Right idea but wrongly executed! Use the solution in post #3 or #4 instead!
 
Last edited:
try criteria of

"[studentid]=" & Me.studentid

or as colin says, use dcount

Code:
if DCount("*", "students","[studentid]=" &  Me.studentid)=0 then
  'no record found
 
if studentID is String:

if DCount("*", "students","[studentid]='" & Me.studentid & "'") =0 then
'no record found
else
'your message
end if
 
if studentID is String:

if DCount("*", "students","[studentid]='" & Me.studentid & "'") =0 then
'no record found
else
'your message
end if
work great
thank you
 
you're welcome :)
 

Users who are viewing this thread

Back
Top Bottom