dbTalk Databases Forums  

Append Query error with apostrophe

comp.databases.ms-access comp.databases.ms-access


Discuss Append Query error with apostrophe in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
kyle
 
Posts: n/a

Default Append Query error with apostrophe - 04-09-2010 , 11:24 AM






I have an append query that works fine unless one of the records
includes an apostrophe.

INSERT INTO [tbInvItems] ( ItemAbb, ItemName, AVIDNO )
SELECT DISTINCT [tbInventory].AVName, [tbInventory].AVDescription,
[tbInventory].AVID
FROM [tbInventory], [tbInvItems]
WHERE ((([tbInventory].AVID)=Forms!frmInventoryEntry!
frmInventorySub.Form!AVID));

I get error 3075: Syntax Error (missing operator) in query expression
'ItemAbb = '25' Cable".

Is there a workaround for this for Append Queries?

Thanks,
Kyle

Reply With Quote
  #2  
Old   
paii, Ron
 
Posts: n/a

Default Re: Append Query error with apostrophe - 04-09-2010 , 12:44 PM






"kyle" <kylek (AT) jsav (DOT) com> wrote

Quote:
I have an append query that works fine unless one of the records
includes an apostrophe.

INSERT INTO [tbInvItems] ( ItemAbb, ItemName, AVIDNO )
SELECT DISTINCT [tbInventory].AVName, [tbInventory].AVDescription,
[tbInventory].AVID
FROM [tbInventory], [tbInvItems]
WHERE ((([tbInventory].AVID)=Forms!frmInventoryEntry!
frmInventorySub.Form!AVID));

I get error 3075: Syntax Error (missing operator) in query expression
'ItemAbb = '25' Cable".

Is there a workaround for this for Append Queries?

Thanks,
Kyle

If you can run it from code; add a parameter to the query then assign the
form value to that.

PARAMETERS AVIDValue Text;
INSERT INTO [tbInvItems] ( ItemAbb, ItemName, AVIDNO )
SELECT DISTINCT [tbInventory].AVName, [tbInventory].AVDescription,
[tbInventory].AVID
FROM [tbInventory], [tbInvItems]
WHERE ((([tbInventory].AVID)=AVIDValue));

See Access help to set the parameter and run the query

Otherwise add a function inside the query to strip-off the offending
characters. You can have the same problem with commas, quotes and some SQL
keywords.

INSERT INTO [tbInvItems] ( ItemAbb, ItemName, AVIDNO )
SELECT DISTINCT [tbInventory].AVName, [tbInventory].AVDescription,
[tbInventory].AVID
FROM [tbInventory], [tbInvItems]
WHERE
((([tbInventory].AVID)=Replace(Forms!frmInventoryEntry!frmInventor ySub.Form!
AVID,"';,""","")));

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.