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

Access VBA: See if a value exists in a column


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
Murray Brown
Murray Brown
1 Solution
Use the DLookup function as follows:

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

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

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

Thank you

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

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