SQL Problem

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 & "');"
 
P

Paolo

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
 
S

Sash

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top