Actually it would compile... but part of it would be displayed in green:
Code:
strQuery = "INSERT INTO PartNumbers (PartNum) VALUES (" '" & sPN & "')"

Originally Posted by
oprache
I do not understand why Visual Studio puts a space between the first double quote and the next single quote. Obviously there is a reason but no luck trying to find any information on the net about that.
That is because the ' character is used to indicate a comment (a note for yourself, which VB ignores). The space (and colour) are being added to alert you to it not being code.
The cause of it being a comment (rather than text) is because you ended the string just before. If you remove the extra double-quote, it might work:
Code:
strQuery = "INSERT INTO PartNumbers (PartNum) VALUES ('" & sPN & "')"
I say might work, because there are lots of potential problems with using string concatenation for this kind of thing - and the suggestion of parameters is the best way (and easiest) to avoid them all.
If the data you are concatenating (in this case sPN) comes from a user (or anything you didn't type), you should consider parameters to be essential.