D
DMUM via AccessMonster.com
Hello, I created a query in the MS Access query window and then copied the
SQL view into my VBA code. Although I've added the quotes and the sql string
designation, I can get the code to be accetable to my VBA code (I have the
code colors on). Here is my query:
strSQL = "INSERT INTO tblTemp_PRSADefLoad (intPRSA, PRSA_Definition,
PRSA_Type) " & _
"SELECT Left([I_PRSA_Reference],InStrRev([I_PRSA_Reference]," ")+2)
AS PRSA, " & _
"tblImportExcel.PRSA_Business_Definition, IIf([PRSA]<>"","Business",
"") AS prsaType " & _
"FROM tblImportExcel;"
This works fine using the MS Access Query window.
Since I don't have to have the portion: SELECT Left([I_PRSA_Reference],
InStrRev([I_PRSA_Reference]," ")+2) AS PRSA, tblImportExcel.
PRSA_Business_Definition,
I re-wrote the query - again in the MS Access query window to look like this:
strSql = "INSERT INTO tblTemp_PRSADefLoad ( intPRSA, PRSA_Definition,
PRSA_Type ) " & _
"SELECT tblImportExcel.PRSA_Business, tblImportExcel.PRSA_Business_Definition,
" & _
"IIf([PRSA_Business]<>"","Business","") AS prsaType " & _
"FROM tblImportExcel;"
This still will not work in my VBA code. I removed the IIF portion of the
code and it finally was accepted by the VBA code window (changed the right
color), so I'm guessing in this case it has to do with the IIF statement, but
I can't for the life of me figure out what is wrong with it.
SQL view into my VBA code. Although I've added the quotes and the sql string
designation, I can get the code to be accetable to my VBA code (I have the
code colors on). Here is my query:
strSQL = "INSERT INTO tblTemp_PRSADefLoad (intPRSA, PRSA_Definition,
PRSA_Type) " & _
"SELECT Left([I_PRSA_Reference],InStrRev([I_PRSA_Reference]," ")+2)
AS PRSA, " & _
"tblImportExcel.PRSA_Business_Definition, IIf([PRSA]<>"","Business",
"") AS prsaType " & _
"FROM tblImportExcel;"
This works fine using the MS Access Query window.
Since I don't have to have the portion: SELECT Left([I_PRSA_Reference],
InStrRev([I_PRSA_Reference]," ")+2) AS PRSA, tblImportExcel.
PRSA_Business_Definition,
I re-wrote the query - again in the MS Access query window to look like this:
strSql = "INSERT INTO tblTemp_PRSADefLoad ( intPRSA, PRSA_Definition,
PRSA_Type ) " & _
"SELECT tblImportExcel.PRSA_Business, tblImportExcel.PRSA_Business_Definition,
" & _
"IIf([PRSA_Business]<>"","Business","") AS prsaType " & _
"FROM tblImportExcel;"
This still will not work in my VBA code. I removed the IIF portion of the
code and it finally was accepted by the VBA code window (changed the right
color), so I'm guessing in this case it has to do with the IIF statement, but
I can't for the life of me figure out what is wrong with it.