Update query - too many " ?

User avatar
Michael Abrams
4StarLounger
Posts: 573
Joined: 10 Feb 2010, 17:32

Update query - too many " ?

Post by Michael Abrams »

Hello,

I have a table with one field (Short text) named EVTS#
It is a 6-digit number. Ex: 123456

I am trying to write an update query for the field to look like this:

“123456”,

I believe I may have too many or too little quotes.
Can you please let me know where I need to fix?

Code: Select all

 “”” & [EVTS#] & “”” & “,” 
Thank you!

User avatar
HansV
Administrator
Posts: 78457
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Update query - too many " ?

Post by HansV »

You cannot use curly quotes in SQL. Try

Code: Select all

"'" & [EVTS#] & "'" & ","
If that doesn't work, please post that fragment in its context.
Best wishes,
Hans

User avatar
Michael Abrams
4StarLounger
Posts: 573
Joined: 10 Feb 2010, 17:32

Re: Update query - too many " ?

Post by Michael Abrams »

:grin: Thank you HansV. I did need a double quote at either end, so I used 2 single quotes and worked great.

Thanks again.

Michael

User avatar
Michael Abrams
4StarLounger
Posts: 573
Joined: 10 Feb 2010, 17:32

Re: Update query - too many " ?

Post by Michael Abrams »

That did not work because when I write the Delete Query, it sees 2 single quotes.

Table where records need deletion - TableA - record to be deleted based on FieldRecNum

Pseudocode:

Delete record from TableA where RecNum In("123456","345678","987654")

User avatar
HansV
Administrator
Posts: 78457
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Update query - too many " ?

Post by HansV »

If RecNum is a number field, you do not need quotes:

DELETE * FROM TableA WHERE RecNum In (123456,345678,987654)

If it is a text field:

DELETE * FROM TableA WHERE RecNum In ('123456','345678','987654')
Best wishes,
Hans

User avatar
Michael Abrams
4StarLounger
Posts: 573
Joined: 10 Feb 2010, 17:32

Re: Update query - too many " ?

Post by Michael Abrams »

Thank you HansV !