• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2853
  • 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

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