简体   繁体   中英

MS Access: VBA SQL Update Query with Ampersand and Text

I have a small syntax problem that I'm hoping someone will help me out with. I need to run a query in MS Access VBA where the record descriptors in Column 2 are updated with two characters from the Left in Column 1 - AND - the text "On0".

I know there's a simple fix like a single apostrophe around a portion of the code, but I've hit a roadblock. Any thoughts?

DoCmd.RunSQL "Update [Table1] SET [Table1].[New Col 2] = Left([Table1].[Old Col 1],2) & "On0";" 

答案是在文本周围放置一个单引号,因此字符串应如下所示:

DoCmd.RunSQL "Update [Table1] SET [Table1].[New Col 2] = Left([Table1].[Old Col 1],2) & 'On0';"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM