Wrap code over 2 lines

  • Thread starter Thread starter Meg
  • Start date Start date
M

Meg

Hi Group!

I am trying to dictate the record source of my report in
the OnOpen code.

My SQL is very long and extends over one line. How can I
break it to run over two lines in the code window?

Thanks
Meg
 
you can use a string variable to hold your sql-statement

like
sSql="SELECT ... FROM ... WHERE ..."
ssql = ssql & " ORDER BY ..."

'or using the line continuation & _
sSQL = "SELECT ..." & _
" FROM ..."

me.recordsource=ssql
 
Meg said:
I am trying to dictate the record source of my report in
the OnOpen code.

My SQL is very long and extends over one line. How can I
break it to run over two lines in the code window?


Another way is to use the standard line continuation
sequence - space underscore:

strSQL = "SELECT f1, f2, " _
& "f3, f4 " _
& "FROM table " _
& "WHERE f3 = ""ABC"" " _
& " AND f4 = 12 " _
& "ORDER BY f1"
' Debug.Print strSQL ' only for testing
 
Back
Top