Hello,
I have a combo box in which I want to display multiple fields by concatenating the fields together. If one of those concatenated fields is Null, then the combo box does not show anything. To rectify this I have created IIf statements to check if certain fields are Null and remove those fields from the concatenation. The problem I am having is how to check if multiple fields are Null. I think I need to use AND in my code, but cannot figure out how to make it work.
My combo box is called cboSite, based on a query called qrySitesAll.
The bound column is an autonumber primary key field called SiteID.
The fields I would like to concatenate into the second column of the combo box (that will be displayed in the combo box) are:
SiteNm
SiteNmAlt (optional)
CmplxNm (optional)
SiteAddr1
SiteBoro
The code below works - it checks if SiteNmAlt is Null and, if Null, excludes SiteNmAlt from the concatenation, then it checks if CmplxNm is Null and, if Null, excludes CmplxNm from the concatenation.
I tried to use the following code to check if both SiteNmAlt and CmplxNm are Null and, if Null, exclude both from the concatenation, but it gave me the error message that I have invalid syntax. I have played with the syntax, but am coming up with no solution.
Does anyone have a suggestion as to how I could improve this syntax, or, alternately, a suggestion for an expression that would allow me to check the fields in each record and exclude null fields from the concatenation?
Thanks in advance,
Bridget
I have a combo box in which I want to display multiple fields by concatenating the fields together. If one of those concatenated fields is Null, then the combo box does not show anything. To rectify this I have created IIf statements to check if certain fields are Null and remove those fields from the concatenation. The problem I am having is how to check if multiple fields are Null. I think I need to use AND in my code, but cannot figure out how to make it work.
My combo box is called cboSite, based on a query called qrySitesAll.
The bound column is an autonumber primary key field called SiteID.
The fields I would like to concatenate into the second column of the combo box (that will be displayed in the combo box) are:
SiteNm
SiteNmAlt (optional)
CmplxNm (optional)
SiteAddr1
SiteBoro
The code below works - it checks if SiteNmAlt is Null and, if Null, excludes SiteNmAlt from the concatenation, then it checks if CmplxNm is Null and, if Null, excludes CmplxNm from the concatenation.
Code:
IIf(IsNull([SiteNmAlt]),[SiteNm]+" of "+[CmplxNm]+", "+[SiteAddr1]+", "+[SiteBoro],IIf(IsNull([CmplxNm]),[SiteNm]+" / "+[SiteNmAlt]+", "+[SiteAddr1]+", "+[SiteBoro],[SiteNm]+" / "+[SiteNmAlt]+" of "+[CmplxNm]+", "+[SiteAddr1]+", "+[SiteBoro]))
Code:
=IIf(AND(IsNull([SiteNmAlt]),IsNull([CmplxNm])),[SiteNm]+", "+[SiteAddr1]+", "+[SiteBoro]IIf(IsNull([SiteNmAlt]),[SiteNm]+" of "+[CmplxNm]+", "+[SiteAddr1]+", "+[SiteBoro],IIf(IsNull([CmplxNm]),[SiteNm]+" / "+[SiteNmAlt]+", "+[SiteAddr1]+", "+[SiteBoro],[SiteNm]+" / "+[SiteNmAlt]+" of "+[CmplxNm]+", "+[SiteAddr1]+", "+[SiteBoro])))
Thanks in advance,
Bridget
Comment