Dlookup - if exists, do this, if not - do that!

This Dlookup looks at a table called dbo_engineers, and if what the use has entered exists returns the number and does some other stuff:

If Nz(DLookup("[Engineer number]", "dbo_Engineers", "[Engineer number] = " & Me!Engineer), "") <> "" Then

'then do this


I would like a message box to come up and say "does not exist" if the lookup above returns no engineer number.

Thanks
Lapchien
LapchienDirectorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

peter57rCommented:
Hello Lapchien,

This assumes 'Engineer number' is a number (not text).

If isnull(DLookup("[Engineer number]", "dbo_Engineers", "[Engineer number] = " & Me!Engineer) Then
    msgbox "Engineer number " & me!engineer & "  does not exist"
else
'do nothing
end if  


Pete
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LapchienDirectorAuthor Commented:
Thanks Pete.  Incidentally, what does the 'Nz' do?

0
peter57rCommented:
The NZ function tests the result of an expression for a Null value and if it finds Null it reurns the value following the comma.
Example
Nz(MYVariable, 'Empty')   returns the text  'Empty'  if MyVariable evaluates to Null.

You can alse use :
nz(<expression>)  without the second parameter.  
In this case if  a non-null <expression> would be a number then NZ returns 0 (zero) ; if the non-null value would be text then NZ returns "".

Pete
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Databases

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.