• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3083
  • Last Modified:

Access VBA: See if a value exists in a column

Hi

What is the best way to see if a certain value exists in a tables's column.

I am archiving data and want to check whether the key field exists in the destination archive table
0
Murray Brown
Asked:
Murray Brown
1 Solution
 
AfsarmCommented:
Use the DLookup function as follows:

If IsNull(DLookup("FieldName","<TableName>","KeyFieldName=<ValueYouWantToCheckFor>)) then
     'It doesn't exist
else
     'it exists
end if

If the keyfield is string, then the value you want to check for must be in quotes.


0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Great answer

Thank you
0
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.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now