Hi
Can someone tell me where the syntax is wrong in the following:-
20 strSQL = "UPDATE Part_Number SET Part_Price_Spare2_Notes = "Open" WHERE Job_PartNumber = '" & Me.PartNoID & ";"
The line of Code is highlighted in Red
Any help appreciated
Hi
Can someone tell me where the syntax is wrong in the following:-
20 strSQL = "UPDATE Part_Number SET Part_Price_Spare2_Notes = "Open" WHERE Job_PartNumber = '" & Me.PartNoID & ";"
The line of Code is highlighted in Red
Any help appreciated
You can PM me if you need further help.
Good Reading https://docs.microsoft.com/en-gb/off...on-description
No red.
Debug.print the sql string and post that.
Most likely your double quotes within double quotes?
Please use # icon on toolbar when posting code snippets.
Cross Posting: https://www.excelguru.ca/content.php?184
Debugging Access: https://www.youtube.com/results?sear...bug+access+vba
Hi Welshgasman
I should have said that both Job_PartNumber and PartNoID are Strings and I cannot change this.
You can PM me if you need further help.
Good Reading https://docs.microsoft.com/en-gb/off...on-description
I cannot understand why it is highlighting "open"
You can PM me if you need further help.
Good Reading https://docs.microsoft.com/en-gb/off...on-description
Try
It's highlighting open because you used double quotes there without escaping. You can use either double " or single ' quotes to open and close a string. If you use double quotes to open and close the string then use single quotation marks to enclose strings within the string, or vise versa. Or you can escape the string characters within the string.Code:strSQL = "UPDATE Part_Number SET Part_Price_Spare2_Notes = 'Open' WHERE Job_PartNumber = '" & Me.PartNoID & "';"
https://software-solutions-online.co...pe-characters/
Please use # icon on toolbar when posting code snippets.
Cross Posting: https://www.excelguru.ca/content.php?184
Debugging Access: https://www.youtube.com/results?sear...bug+access+vba
I was always under the impression if I was using text then they should always be enclosed in Double Quotes.
If I was making a reference to a Control whose data type was Text then use a Single & Double to enclose.
You can PM me if you need further help.
Good Reading https://docs.microsoft.com/en-gb/off...on-description
Text is text?
So how is Access meant to know when the string ends as opposed to a value being added?
@kd2017 has posted some code, which I would have thought was the solution?, just that I wanted you to think for it by yourself. Have you tried that?
Please use # icon on toolbar when posting code snippets.
Cross Posting: https://www.excelguru.ca/content.php?184
Debugging Access: https://www.youtube.com/results?sear...bug+access+vba
Hi KD
That didn't work either - gives the error Too Few Parameters. Expected 1
I have gone with an Update query and it works just fine
Many thanks for looking
You can PM me if you need further help.
Good Reading https://docs.microsoft.com/en-gb/off...on-description