How to use ISNULL function in ms-access

I have a database table with the following fields

FieldId FieldGroupId FieldName

I need to select FieldGroupId from the Fields table, where FieldId = "?" and iff FieldGroupId is empty, it should return the default value.

The following query does not work if the field identifier is not in the database.

select IIf(IsNull(FieldGroupID),"AA",FieldGroupID) from Fields where FieldID ='ALPHAA'
+3
source share
1 answer

If you will do this from an Access application session, you can use DLookup()to get the value FieldGroupIDthat matches your value FieldID.

DLookup("FieldGroupID", "[Fields]", "FieldID ='ALPHAA'")

DLookup()will give you Null if FieldIDnot found. You can use the function Nz()to replace the desired value for Null.

Nz(DLookup("FieldGroupID", "[Fields]", "FieldID ='ALPHAA'"), "AA")
+3
source

All Articles