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'
If you will be doing this from within an Access application session, you can use
DLookup()to retrieve theFieldGroupIDvalue which matches yourFieldIDvalue.DLookup()will give you Null whenFieldIDis not found. You can use theNz()function to substitute your desired value for Null.