probs using line continuation characters

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MLH

    probs using line continuation characters

    I don't understand why (a) works and compiles but (b) does not...

    (a)
    Set qdfTemp = .CreateQueryDef ("", _
    "SELECT * FROM Employees")

    (b)
    Set qdfTemp = .CreateQueryDef ("", _
    "SELECT DISTINCTROW tblPmtsRcd.PmtI D,
    tblPmtsRcd.Invo iceNumber, tblPmtsRcd.Vehi cleJobID,
    tblPmtsRcd.PmtR ecTDStamp _
    FROM tblPmtsRcd LEFT JOIN tblinvoiceData ON
    tblPmtsRcd.Invo iceNumber = tblinvoiceData. InvoiceNumber _
    WHERE tblPmtsRcd.Invo iceNumber<>0 And tblPmtsRcd.Invo iceNumber
    Is Not Null AND tblinvoiceData. InvoiceNumber Is Null")
    ' Open Recordset and print report.
    GetrstTemp qdfTemp

    Isn't (b) just a longer SQL string with continuation characters and
    (a) a shorter SQL string with continuation characters?

    Everytime I type the Set statement in (b) into a module, it turns
    red and gives me an error. I do not recognize what is wrong.
    With the damned newsreader wrapping - you may not be able
    to see what I'm doing wrong either. Sorry about that. Would
    like to know. If I type EVERYTHING on one line - no problem.
    But when I try using line continuation characters everything
    turns red.
  • Arch

    #2
    Re: probs using line continuation characters

    On Thu, 01 May 2008 19:10:57 -0400, MLH <CRCI@NorthStat e.netwrote:
    >I don't understand why (a) works and compiles but (b) does not...
    >
    >(a)
    Set qdfTemp = .CreateQueryDef ("", _
    "SELECT * FROM Employees")
    >
    >(b)
    Set qdfTemp = .CreateQueryDef ("", _
    "SELECT DISTINCTROW tblPmtsRcd.PmtI D,
    >tblPmtsRcd.Inv oiceNumber, tblPmtsRcd.Vehi cleJobID,
    >tblPmtsRcd.Pmt RecTDStamp _
    FROM tblPmtsRcd LEFT JOIN tblinvoiceData ON
    >tblPmtsRcd.Inv oiceNumber = tblinvoiceData. InvoiceNumber _
    WHERE tblPmtsRcd.Invo iceNumber<>0 And tblPmtsRcd.Invo iceNumber
    >Is Not Null AND tblinvoiceData. InvoiceNumber Is Null")
    ' Open Recordset and print report.
    GetrstTemp qdfTemp
    >
    >Isn't (b) just a longer SQL string with continuation characters and
    >(a) a shorter SQL string with continuation characters?
    >
    >Everytime I type the Set statement in (b) into a module, it turns
    >red and gives me an error. I do not recognize what is wrong.
    >With the damned newsreader wrapping - you may not be able
    >to see what I'm doing wrong either. Sorry about that. Would
    >like to know. If I type EVERYTHING on one line - no problem.
    >But when I try using line continuation characters everything
    >turns red.
    In b, you have the continuation character in the middle of a literal
    string (" on both ends), but not in a.

    If you need to continue a literal string there are a couple of options

    SQL = "First part of the string " & _
    "continuati on of string " & _
    "last line of string"

    SQL = "First part of the string " _
    & "continuati on of string " _
    & "last line of string"

    Comment

    • MLH

      #3
      Re: probs using line continuation characters

      Are you sure I'm in the middle of a literal string?
      I don't think that's the case.

      >
      >In b, you have the continuation character in the middle of a literal
      >string (" on both ends), but not in a.
      >
      >If you need to continue a literal string there are a couple of options
      >
      >SQL = "First part of the string " & _
      > "continuati on of string " & _
      > "last line of string"
      >
      >SQL = "First part of the string " _
      > & "continuati on of string " _
      > & "last line of string"

      Comment

      • MLH

        #4
        Re: probs using line continuation characters

        Oops. My bad. Sorry... now I see it.

        Comment

        Working...