How to break long string to multiple lines

calendar_today Asked May 18, 2013
thumb_up 17 upvotes
history Updated April 16, 2026

Question posted 2013 · +13 upvotes

I’m using this insert statement in my code in vba excel but i’m not able to break it into more than one line

SqlQueryString = "Insert into Employee values(" & txtEmployeeNo.Value & " _
,'" & txtContractStartDate.Value & "' _
,'" & txtSeatNo.Value & "' _
,'" & txtFloor.Value & "','" & txtLeaves.Value & "')"

It is giving error “Expected end of statement”. Plz help.

Accepted answer +17 upvotes

You cannot use the VB line-continuation character inside of a string.

SqlQueryString = "Insert into Employee values(" & txtEmployeeNo.Value & _
"','" & txtContractStartDate.Value &  _
"','" & txtSeatNo.Value & _
"','" & txtFloor.Value & "','" & txtLeaves.Value & "')"

Top excel-vba Q&A (6)

+17 upvotes ranks this answer #25 out of 136 excel-vba solutions on this site — top 18%.