SQL Problem

  • Thread starter Thread starter Sash
  • Start date Start date
S

Sash

I have the following statement and the problem is that me!DESCR may contain a
single quote or comma which in turn throws off my statement. Can someone
help???

strsql = "insert into June_Location_ItemMaster (ITEM_NO, DESCR, MFR, MFRCat,
Inv_INV_QTY, PRICE, Inv_LOCATION, Inv_ID, DateCounted)VALUES('" & Me!ITEM_NO
& "', '" & Me!DESCR & "', '" & Me!MFR & "', '" & Me!MFRCat & "'," &
Me!INV_QTY & ", " & intPrice & ", '" & Me!LOCATION & "', " & Me!ID & ", '" &
Me!DateCounted & "');"
 
Hi Sash,

Try in this way

strsql = "insert into June_Location_ItemMaster (ITEM_NO, DESCR, MFR, MFRCat,
Inv_INV_QTY, PRICE, Inv_LOCATION, Inv_ID, DateCounted)VALUES('" & Me!ITEM_NO
& "', """ & Me!DESCR & """, '" & Me!MFR & "', '" & Me!MFRCat & "'," &
Me!INV_QTY & ", " & intPrice & ", '" & Me!LOCATION & "', " & Me!ID & ", '" &
Me!DateCounted & "');"

I've substituted the single quote with two double quote and this should do
the trick

HTH Paolo
 
PERFECT!!! Thank you so much.

Paolo said:
Hi Sash,

Try in this way

strsql = "insert into June_Location_ItemMaster (ITEM_NO, DESCR, MFR, MFRCat,
Inv_INV_QTY, PRICE, Inv_LOCATION, Inv_ID, DateCounted)VALUES('" & Me!ITEM_NO
& "', """ & Me!DESCR & """, '" & Me!MFR & "', '" & Me!MFRCat & "'," &
Me!INV_QTY & ", " & intPrice & ", '" & Me!LOCATION & "', " & Me!ID & ", '" &
Me!DateCounted & "');"

I've substituted the single quote with two double quote and this should do
the trick

HTH Paolo
 
Back
Top