View Full Version : Update Query Punctuation


Lisa_Wilderspin
08-06-2001, 02:18 AM
I have a form (UpdateTS)with text boxes (i.e NewTSTitle) on for updating data in a table.
I've written an update query but the following bit just won't work.

Title = Forms![UpdateTS]![NewTSTitle]

Text with " or ' is sometimes entered into this textbox (on the form).
I know there is some sort of rule about doubling the " marks if they
appear in the text but i've read a few conflicting posts on various groups and am now
confused (it doesn't take much!).
I've tried a few combinations of ", & and ' surrounding the
Forms![UpdateTS]![NewTSTitle] part but when i run the query (via
OpenQuery Macro from command button on the form), it puts the sql in
the field on the table rather than inputting the text in the text box. If i don't put any punctuation around the expression i get an "Invalid Argumnet" message.

Does anyone have an idea what i'm doing wrong?
Any help would be appreciated as i'm fairly new to all of this !
Thanks in advance.

Lisa

The_Doc_Man
08-06-2001, 09:55 AM
There are issues with quote-marks but only apply if you are building a string on the fly from components.

For instance, to build a SELECT clause on the fly for an arbitrary text match,...

strSelect = "SELECT * FROM MyTable WHERE [MyField] = """ & Trim$(Me![MyChoice]) & """ AND [Eligible] = True"

You need to double up on the quotes that you want in the string. If [MyChoice] contains the string "XYZ" (without the actual quotes), the value of strSelect would become

SELECT * FROM MyTable WHERE [MyField] = "XYZ" and [Eligible] = True

If you are not doing concatenation-style substitution, doubling up on the quotes should not matter that much. Though every now and then Access trips me up on this. It also would matter in some functions that accept a string as input and return a string as output, but that appears to be on a case by case basis.

Lisa_Wilderspin
08-07-2001, 05:06 AM
Thanks for the suggestion.
Earlier today i converted the database from Acc2000 to 97 to test another part of it in Runtime. I tested the query out of curiosity and it seems to work perfectly in the 97 runtime version.
I've spent the past few hours re-running it as i'm a bit nervous about trusting it and it still keeps working!
Could this be some sort of bug?

Pat Hartman
08-08-2001, 05:49 AM
Make sure that some of the rows actually contain the single or double quotes in the title column.