Actually it would compile... but part of it would be displayed in green:
strQuery = "INSERT INTO PartNumbers (PartNum) VALUES (" '" & sPN & "')"
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.
Originally Posted by oprache
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:
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.
strQuery = "INSERT INTO PartNumbers (PartNum) VALUES ('" & sPN & "')"
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.