Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21
  1. #16
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I've never seen that, but I'm glad you got it working. If you want to fix having the SQL in VBA, post the code here.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  2. #17
    schulzy175 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Oct 2017
    Posts
    98
    So I found where I was being tricked. All my action queries are based off my main query titled "PriorSales_Append". This query was never run first so therefore, none of my other action queries had sales to populate and append. I switched my code around to where "PriorSales_Append" is run first and sure enough I've been able to run it just fine everytime. I found this out because it was appending 0 rows on all my other action queries so that only lead me to "PriorSales_Append" to be run first. Note To Self!: Append your sales first :P

  3. #18
    schulzy175 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Oct 2017
    Posts
    98
    Quote Originally Posted by pbaldy View Post
    I've never seen that, but I'm glad you got it working. If you want to fix having the SQL in VBA, post the code here.
    Gladly. When I come across a problem, I don't like to set it aside for another solution because I want to learn as much as I can.

    So here is the SQL that Access had made.

    Code:
    INSERT INTO LMSB_Volume_Append ( MTH, SITENAME, [Count] )
    SELECT LMSB_Volume_Q.Month, LMSB_Volume_Q.SITENAME, Sum(LMSB_Volume_Q.CountOfNAME) AS SumOfCountOfNAME
    FROM LMSB_Volume_Q
    GROUP BY LMSB_Volume_Q.Month, LMSB_Volume_Q.SITENAME;
    I went ahead and readjusted the code for VBA as follows:

    Code:
    "INSERT INTO LMSB_Volume_Append ( MTH, SITENAME, [Count] )" & _
    "SELECT LMSB_Volume_Q.Month, LMSB_Volume_Q.SITENAME, Sum(LMSB_Volume_Q.CountOfNAME) AS SumOfCountOfNAME" & _
    "FROM LMSB_Volume_Q" & _
    "GROUP BY LMSB_Volume_Q.Month, LMSB_Volume_Q.SITENAME;"
    Again, the error I receive is "Query must contain at least one query or table." People have stated online that there may need to be extra spaces or some fields need to be in brackets because the field name may be the same as Access's Default name types. i.e. Month, Day, Name, etc. I adjusted the sql as much as I could see would need changing, but I could never get it to run.

  4. #19
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Use this to see what the final SQL looks like:

    http://www.baldyweb.com/ImmediateWindow.htm

    Right off, you will end up with each line running into the next because you have no spaces either at the end or the beginning. In other words:

    ...SumOfCountOfNAMEFROM...
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #20
    schulzy175 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Oct 2017
    Posts
    98
    I used debug.print to test and check my sql, but it wouldn't wrap the text with delimiters?

  6. #21
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I assumed you were setting a variable, so you'd debug that:

    strSQL = "INSERT..."

    debug.print strSQL
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 01-24-2017, 08:26 AM
  2. Replies: 5
    Last Post: 12-15-2015, 07:11 AM
  3. Replies: 2
    Last Post: 08-12-2012, 10:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums