Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Richland, Washington, USA
    Posts
    407
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VBA Line Continuation Annoyance (Access 2000 (9.0.4402 SR-1))

    This, I think, is really a VBA annoyance, but since I'm using it with Access, I'm posting the question here.

    When I create a statement that's continued on a second line for a series of dates as the argument list for the Array() function, VBA (in its infinite wisdom) divides the statement in a different place when the final return is entered at the end of the statement (i.e., when it syntax-checks the statement). As is, it works fine (no syntax errors). The problem is that if I copy this same statement to reuse it somewhere else, VBA gives me a syntax error as soon as I paste it back!!! If I edit the statement back to the way I originally typed it in, VBA divides it like it did above and does not generate the syntax error.

    Here's an example (try it!). Type in:

    <font face="Georgia"> Holidays = Array(#1/1/03#, _
    #2/17/03#)
    </font face=georgia>
    When you finish entering the statement, VBA rewrites it as:

    <font face="Georgia"> Holidays = Array(#1/1/2003#, # _
    2/17/2003#)
    </font face=georgia>
    Left alone, this works fine. But try copying (or cutting) this statement and pasting it. You get a syntax error! You have to edit it back to the way you typed it in, let VBA butcher it, and then it will accept it (in its butchered form).

    Does anyone have an explanation for this behavior?

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: VBA Line Continuation Annoyance (Access 2000 (9.0.4402 SR-1))

    Annoying indeed, and one to remember.
    Pat <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  3. #3
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA Line Continuation Annoyance (Access 2000 (9.0.4402 SR-1))

    That is definitely annoying. You can get around it by putting the underscore in front of the comma like this:

    <pre> Holidays = Array(#1/1/2003# _
    , #2/17/2003#)
    </pre>

    Legare Coleman

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •