P
potsy via AccessMonster.com
I am trying to use DoCmd.RunSQL with the following...
INSERT INTO tbl_BEACH_ALL ( Security_Name_Import, CUSIP, Beach_Field, Who,
[Desc], Cpn, Mat, Call, Amt, Tp, Sprd, Tsy, Prc, Yld, Edte, Udte, Fl )
SELECT (IIf(IsNull(tbl_BEACH_AGY!CUSIP),tbl_BEACH_AGY!Desc & " " & Round
(tbl_BEACH_AGY!Cpn,3) & " " & tbl_BEACH_AGY!Mat & " Corp",tbl_BEACH_AGY!CUSIP
& " Corp")) AS New_Sec_Field, tbl_BEACH_AGY.CUSIP, tbl_BEACH_AGY!Desc & " " &
Round(tbl_BEACH_AGY!Cpn,3) & " " & Format(tbl_BEACH_AGY!Mat,"mm/dd/yyyy") AS
Beach_Field, tbl_BEACH_AGY.Who, tbl_BEACH_AGY.Desc, tbl_BEACH_AGY.Cpn,
tbl_BEACH_AGY.Mat, tbl_BEACH_AGY.Call, tbl_BEACH_AGY.Amt, tbl_BEACH_AGY.Tp,
tbl_BEACH_AGY.Sprd, tbl_BEACH_AGY.Tsy, tbl_BEACH_AGY.Prc, tbl_BEACH_AGY.Yld,
tbl_BEACH_AGY.Edate, tbl_BEACH_AGY.Udate, tbl_BEACH_AGY.Fl
FROM tbl_BEACH_AGY
GROUP BY (IIf(IsNull(tbl_BEACH_AGY!CUSIP),tbl_BEACH_AGY!Desc & " " & Round
(tbl_BEACH_AGY!Cpn,3) & " " & tbl_BEACH_AGY!Mat & " Corp",tbl_BEACH_AGY!CUSIP
& " Corp")), tbl_BEACH_AGY.CUSIP, tbl_BEACH_AGY!Desc & " " & Round
(tbl_BEACH_AGY!Cpn,3) & " " & Format(tbl_BEACH_AGY!Mat,"mm/dd/yyyy"),
tbl_BEACH_AGY.Who, tbl_BEACH_AGY.Desc, tbl_BEACH_AGY.Cpn, tbl_BEACH_AGY.Mat,
tbl_BEACH_AGY.Call, tbl_BEACH_AGY.Amt, tbl_BEACH_AGY.Tp, tbl_BEACH_AGY.Sprd,
tbl_BEACH_AGY.Tsy, tbl_BEACH_AGY.Prc, tbl_BEACH_AGY.Yld, tbl_BEACH_AGY.Edate,
tbl_BEACH_AGY.Udate, tbl_BEACH_AGY.Fl
HAVING (((Count((IIf(IsNull([tbl_BEACH_AGY]![CUSIP]),[tbl_BEACH_AGY]![Desc] &
" " & Round([tbl_BEACH_AGY]![Cpn],3) & " " & [tbl_BEACH_AGY]![Mat] & " Corp",
[tbl_BEACH_AGY]![CUSIP] & " Corp"))))>=1));
I''ve copied the above SQL from a query and tried to paste it into a VB
module but the code changes the font color to red. Obviously, because there
is an error. Sorry but I am not sure how to covert this SQL to work in VB.
Any suggestions? Would someone "please" be kind enough to write the correct
code so I can copy it into VB module? I know I am asking a lot but I cant
find the error. I've concluded it has something to do with a lines of code
in the module and/or maybe the "IIf" statement???
INSERT INTO tbl_BEACH_ALL ( Security_Name_Import, CUSIP, Beach_Field, Who,
[Desc], Cpn, Mat, Call, Amt, Tp, Sprd, Tsy, Prc, Yld, Edte, Udte, Fl )
SELECT (IIf(IsNull(tbl_BEACH_AGY!CUSIP),tbl_BEACH_AGY!Desc & " " & Round
(tbl_BEACH_AGY!Cpn,3) & " " & tbl_BEACH_AGY!Mat & " Corp",tbl_BEACH_AGY!CUSIP
& " Corp")) AS New_Sec_Field, tbl_BEACH_AGY.CUSIP, tbl_BEACH_AGY!Desc & " " &
Round(tbl_BEACH_AGY!Cpn,3) & " " & Format(tbl_BEACH_AGY!Mat,"mm/dd/yyyy") AS
Beach_Field, tbl_BEACH_AGY.Who, tbl_BEACH_AGY.Desc, tbl_BEACH_AGY.Cpn,
tbl_BEACH_AGY.Mat, tbl_BEACH_AGY.Call, tbl_BEACH_AGY.Amt, tbl_BEACH_AGY.Tp,
tbl_BEACH_AGY.Sprd, tbl_BEACH_AGY.Tsy, tbl_BEACH_AGY.Prc, tbl_BEACH_AGY.Yld,
tbl_BEACH_AGY.Edate, tbl_BEACH_AGY.Udate, tbl_BEACH_AGY.Fl
FROM tbl_BEACH_AGY
GROUP BY (IIf(IsNull(tbl_BEACH_AGY!CUSIP),tbl_BEACH_AGY!Desc & " " & Round
(tbl_BEACH_AGY!Cpn,3) & " " & tbl_BEACH_AGY!Mat & " Corp",tbl_BEACH_AGY!CUSIP
& " Corp")), tbl_BEACH_AGY.CUSIP, tbl_BEACH_AGY!Desc & " " & Round
(tbl_BEACH_AGY!Cpn,3) & " " & Format(tbl_BEACH_AGY!Mat,"mm/dd/yyyy"),
tbl_BEACH_AGY.Who, tbl_BEACH_AGY.Desc, tbl_BEACH_AGY.Cpn, tbl_BEACH_AGY.Mat,
tbl_BEACH_AGY.Call, tbl_BEACH_AGY.Amt, tbl_BEACH_AGY.Tp, tbl_BEACH_AGY.Sprd,
tbl_BEACH_AGY.Tsy, tbl_BEACH_AGY.Prc, tbl_BEACH_AGY.Yld, tbl_BEACH_AGY.Edate,
tbl_BEACH_AGY.Udate, tbl_BEACH_AGY.Fl
HAVING (((Count((IIf(IsNull([tbl_BEACH_AGY]![CUSIP]),[tbl_BEACH_AGY]![Desc] &
" " & Round([tbl_BEACH_AGY]![Cpn],3) & " " & [tbl_BEACH_AGY]![Mat] & " Corp",
[tbl_BEACH_AGY]![CUSIP] & " Corp"))))>=1));
I''ve copied the above SQL from a query and tried to paste it into a VB
module but the code changes the font color to red. Obviously, because there
is an error. Sorry but I am not sure how to covert this SQL to work in VB.
Any suggestions? Would someone "please" be kind enough to write the correct
code so I can copy it into VB module? I know I am asking a lot but I cant
find the error. I've concluded it has something to do with a lines of code
in the module and/or maybe the "IIf" statement???