Search code examples
ms-accessvbaline-breaks

Using linebreak to break IF statement in Access VBA


I have a VBA conditional script as below:

If COMORBIDITY_CANCER = -1 Or COMORBIDITY_CHRONIC_SKIN_LESIONS = -1 Or COMORBIDITY_CHRONIC_LUNG_DISEASE = -1 Or COMORBIDITY_CARDIOVASCULAR_DISEASE = -1 Or COMORBIDITY_DM = -1 Or COMORBIDITY_IMMUNODEFICIENCY_OR_CHEMOTHERAPY = -1 Or COMORBIDITY_ADL = -1 Or COMORBIDITY_HEPATIC_DISEASE = -1 Or COMORBIDITY_RENAL_IMPAIRMENT = -1 Then
RS_REPORT.AddNew
RS_REPORT!REPORT_UID = REPORT_UID
RS_REPORT!CATEGORY1_ID = 2
RS_REPORT!CATEGORY2_ID = 1
RS_REPORT!CATEGORY3_ID = 1
RS_REPORT.Update
End If

I think the first line of it is too long and I would like to chop it using ENTER, like what can be done in R, but seems it is invalid in VBA, I tried

& _ 

but it also fails.

Any suggestions? Thanks!


Solution

  • Try this:

    If COMORBIDITY_CANCER = -1 Or COMORBIDITY_CHRONIC_SKIN_LESIONS = -1 Or _
    COMORBIDITY_CHRONIC_LUNG_DISEASE = -1 Or COMORBIDITY_CARDIOVASCULAR_DISEASE = -1 Or _
    COMORBIDITY_DM = -1 Or COMORBIDITY_IMMUNODEFICIENCY_OR_CHEMOTHERAPY = -1 Or _
    COMORBIDITY_ADL = -1 Or COMORBIDITY_HEPATIC_DISEASE = -1 Or _
    COMORBIDITY_RENAL_IMPAIRMENT = -1 Then