UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Combo Box On Not In List    
 
   
peaitch
post Apr 9 2005, 10:17 PM
Post #1

New Member
Posts: 2



On my form I have a combo box with an On Not In List Event. To insert the new data in to the appropriate table I build up a SQL string as follows:

'Build up the SQL string to add new data.
strSQL = "INSERT INTO [tblMy Table Name]([fldItemName]) " & _
"VALUES ('" & NewData & "');"

I then perform the action

DoCmd.RunSQL strSQL

This works OK until the new data contains and apostrophe eg "Fred's CD". The error message 3075 - Syntax error, missing operator is displayed.

How can I resolve this problem?

Thanking you in advance.
pH
Go to the top of the page
 
+
R. Hicks
post Apr 9 2005, 10:24 PM
Post #2

UA Forum Administrator
Posts: 38,073
From: Birmingham, Alabama USA



Try changing you SQL to:
CODE
strSQL = "INSERT INTO [tblMy Table Name]([fldItemName]) " & _
"VALUES ('" & Chr(34) & NewData & Chr(34) & "');"

RDH
Go to the top of the page
 
+
peaitch
post Apr 10 2005, 12:46 AM
Post #3

New Member
Posts: 2



Dear Ricky

Thanks for your suggestion.

It resulted in another VBA error - but it pointed me in the right direction. The solution that worked is

'Build up the SQL string to add new data.
strSQL = "INSERT INTO [tblMy Table Name]([fldItemType]) " & _
"VALUES (" & Chr(34) & NewData & Chr(34) & ");"

Many thanks

pH
Go to the top of the page
 
+
R. Hicks
post Apr 10 2005, 07:56 AM
Post #4

UA Forum Administrator
Posts: 38,073
From: Birmingham, Alabama USA



Glad you got it going .. you are welcome .. (IMG:http://www.utteraccess.com/forum/style_emoticons/default/wink.gif)

RDH
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 18th May 2013 - 11:11 AM