我对VBA气氛完全陌生。我试图将这条线分成多行,但我失败了。有人可以帮我把这段代码分成多行吗?
DoCmd.RunSQL "UPDATE INDIVIDUAL SET INDIVIDUAL.INDI_FIRSTNAME = '" & prospect_contact!FirstName & "', INDIVIDUAL.INDI_LASTNAME = '" & prospect_contact!LastName & "', INDIVIDUAL.INDI_TEL = '" & prospect_contact!BusinessTelephone & "', INDIVIDUAL.INDI_ADDRESS1 = '" & Replace(prospect_contact!Street, "'", "") & "', INDIVIDUAL.INDI_ADDRESS2 = '" & Replace(prospect_contact!Street1, "'", "") & "', INDI_STATUS = '" & pro & "',INDIVIDUAL.INDI_FUNEL1 = '" & prospect_contact!QualificationStatus & "', INDIVIDUAL.INDI_COUNTRY = '" & prospect_contact!Country_Employer & "', INDIVIDUAL.ACCT_NAME = '" & Replace(prospect_contact!Employer, "'", "") & "' WHERE INDIVIDUAL.INDI_FULLNAME = '" & key & "';"
更新:我尝试使用& _但是我收到语法错误,代码在VBA中变为红色。 我用逗号或引号搞错了。我不知道。
DoCmd.RunSQL "UPDATE INDIVIDUAL SET INDIVIDUAL.INDI_FIRSTNAME = '" & prospect_contact!FirstName & "', & _
INDIVIDUAL.INDI_LASTNAME = '" & prospect_contact!LastName & "', & _
INDIVIDUAL.INDI_TEL = '" & prospect_contact!BusinessTelephone & "', & _
INDIVIDUAL.INDI_ADDRESS1 = '" & Replace(prospect_contact!Street, "'", "") & "', & _
INDIVIDUAL.INDI_FUNEL1 = '" & prospect_contact!QualificationStatus & "', & _
INDI_STATUS = '" & pro & "', & _
INDIVIDUAL.INDI_COUNTRY = '" & prospect_contact!Country_Employer & "', & _
INDIVIDUAL.ACCT_NAME = '" & Replace(prospect_contact!Employer, "'", "") & "' & _
WHERE INDIVIDUAL.INDI_FULLNAME = '" & key & "';"
更新2:
IT工作!有用!有用!感谢@Bathsheba,@ TheLaurens:)
答案 0 :(得分:11)
在VBA中,一个空格后跟下划线,没有,之后会给你一个换行符。
e.g。
DoCmd.RunSQL "UPDATE INDIVIDUAL SET INDIVIDUAL.INDI_FIRSTNAME = '" & _
prospect_contact!FirstName & "', INDIVIDUAL.INDI_LASTNAME = '" & _
etc
但是不要在字符串文字中断行:这是语法错误。
您可以拥有的换行次数有一个惊人的小限制。