How to use ISNULL function in ms-access

ms-access, ms-access-2003

Solution

If you will be doing this from within an Access application session, you can use `DLookup()` to retrieve the `FieldGroupID` value which matches your `FieldID` value.

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

`DLookup()` will give you Null when `FieldID` is not found. You can use the `Nz()` function to substitute your desired value for Null.

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

Problem

I have database table with following fields FieldId FieldGroupId FieldName I need to select FieldGroupId from Fields table where FieldId = "?" and iff FieldGroupId is empty it should return some default value. Following query does not work if FieldID is not present in databse. ``` select IIf(IsNull(FieldGroupID),"AA",FieldGroupID) from Fields where FieldID ='ALPHAA' ```

Original source