Hi,
I have been having a problem with an IIF statement in SQL, I have been able to get it to work for other parts of the sql statement, except for one. I want to put an IIF statement on the statement in bold below:
strSQL = "INSERT INTO ma_enq ( A4, A1, A2, A3 ) " & _
"SELECT I1.postcode, " & _
"Mid$(';' & I1.PRMF & ';',S1.num+1,S2.num-S1.num-1) & IIf(Trim(I1.Strd & '')='','',','+I1.Strd) & IIf(Trim(I1.STR & '')='','',', '+I1.STR), " & _
"IIF(IsNull([I1].[Locdd]),[I1].[Locd],[I1].[Locdd] & IIf(IsNull([Locd]),'',', ' & [Locd])) AS Expr1, IIF(IsNull([I1].[PTN]),[I1].[CNT],[I1].[PTN] & IIf(IsNull([CNT]),'',', ' & [CNT])) AS Expr2 " & _
"FROM ma_dbo_uk AS I1, integers AS S1, integers AS S2 " & _
"WHERE (((Mid$(';' & [I1].[PRMF] & ';',[S1].[num]+1,[S2].[num]-[S1].[num]-1))=[Forms]![Ma_search2]![PRMF_a1]) AND ((Mid$(';' & [I1].[PRMF] & ';',[S1].[num],1))=';') AND ((Mid$(';' & [I1].[PRMF] & ';',[S2].[num],1))=';') AND (([S1].[num]+1)<[S2].[num]) AND ((InStr(1,Mid$(';' & [I1].[PRMF] & ';',[S1].[num]+1,[S2].[num]-[S1].[num]-1),';'))=0));"
I want the line above to take into account null records, because at present if there is a record with a null value in the field in bold it will not append it.
Any suggestions very much appreciated. Thanks in advance,
M-.
I have been having a problem with an IIF statement in SQL, I have been able to get it to work for other parts of the sql statement, except for one. I want to put an IIF statement on the statement in bold below:
strSQL = "INSERT INTO ma_enq ( A4, A1, A2, A3 ) " & _
"SELECT I1.postcode, " & _
"Mid$(';' & I1.PRMF & ';',S1.num+1,S2.num-S1.num-1) & IIf(Trim(I1.Strd & '')='','',','+I1.Strd) & IIf(Trim(I1.STR & '')='','',', '+I1.STR), " & _
"IIF(IsNull([I1].[Locdd]),[I1].[Locd],[I1].[Locdd] & IIf(IsNull([Locd]),'',', ' & [Locd])) AS Expr1, IIF(IsNull([I1].[PTN]),[I1].[CNT],[I1].[PTN] & IIf(IsNull([CNT]),'',', ' & [CNT])) AS Expr2 " & _
"FROM ma_dbo_uk AS I1, integers AS S1, integers AS S2 " & _
"WHERE (((Mid$(';' & [I1].[PRMF] & ';',[S1].[num]+1,[S2].[num]-[S1].[num]-1))=[Forms]![Ma_search2]![PRMF_a1]) AND ((Mid$(';' & [I1].[PRMF] & ';',[S1].[num],1))=';') AND ((Mid$(';' & [I1].[PRMF] & ';',[S2].[num],1))=';') AND (([S1].[num]+1)<[S2].[num]) AND ((InStr(1,Mid$(';' & [I1].[PRMF] & ';',[S1].[num]+1,[S2].[num]-[S1].[num]-1),';'))=0));"
I want the line above to take into account null records, because at present if there is a record with a null value in the field in bold it will not append it.
Any suggestions very much appreciated. Thanks in advance,
M-.