Consulting

Results 1 to 5 of 5

Thread: Record Macro won't complete query lenth

  1. #1
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    221
    Location

    Record Macro won't complete query lenth

    I want to make my query dynamic and use cells as the date parameter. When I go to record the macro though, the query seems to be too long to record. I had this working in another file, and Im not quite sure how to write the rest out?? Is there an easier way to do this?

  2. #2
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    221
    Location
    what do the chr(10) an chr(13) do ?

    [vba]
    ..."SELECT"&chr(13)&""&chr(10)&...
    [/vba]

    I think if I can figure this part out, I should be able to finish writing the query myself in vba.

  3. #3
    Administrator
    2nd VP-Knowledge Base
    VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    Chr(10) = Linefeed
    Chr(13) = Carriage Return

    But you don't have to use that in a SQL query, just so you know. Also, the combo of those 2 character codes is equivalent to using vbCrLf like
    [VBA]..."SELECT" & vbCrLf & "From"...[/VBA]

    How long is the query? How many characters is it?




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  4. #4
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    221
    Location
    1355 with spaces, 1,294 without.

  5. #5
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    221
    Location
    Here is an example of how I am trying to do it ...
    [vba]
    .CommandText = Array( _
    "SELECT" & vbCrLf & _
    "a.itemA,a.itemB,a.itemC,a.itemA,a.ItemD,a.ItemE,a.ItemF," &vbCrLf& _ a.ItemG,a.ItemH,a.ItemI," & vbCrLf & _
    "a.itemJ,a.itemK,a.itemL,a.itemM..." & vbCrLf & _
    [/vba] etc.



    The table has many fields I require (about 30, then about 20 + in the group by clause, but the table just has too many fields (200 +) to pull the whole thing back. That is why it is so long.

Posting Permissions

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