Results 1 to 4 of 4
  1. #1
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544

    Question Performing count in VBA

    I'm not sure if this is going to be an easy fix, but gotta ask. I have this SQL statement that I want to run in VBA. The append part does not bother me, it is the count part that bothers me. Any suggestions?



    Code:
    INSERT INTO tblCountAssign ( CountOfAuto, RV )
    SELECT Count(AcctPeriods.Auto) AS CountOfAuto, AcctPeriods.RV
    FROM AcctPeriods
    WHERE (((AcctPeriods.RV)=[Forms]![SfrmAssign]![cboRACF]))
    GROUP BY AcctPeriods.RV;

  2. #2
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    I am getting a syntax error of missing operator
    Code:
        mySQL = "INSERT INTO tblCountAssign (CountOfAuto, RV ) SELECT (Count(AcctPeriods.Auto) AS CountOfAuto, AcctPeriods.RV) FROM AcctPeriods WHERE (((AcctPeriods.RV) = varRACF))GROUP BY AcctPeriods.RV;"
        CurrentDb.Execute mySQL, dbFailOnError

  3. #3
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    check this out:

    http://office.microsoft.com/en-us/ac...001231483.aspx


    using a GROUP BY needs a HAVING clause as a substitute for the WHERE clause doesn't it? HAVING comes after GROUP BY clause as well, which is different than the WHERE clause.

  4. #4
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Thank you!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. count query
    By lmp101010 in forum Queries
    Replies: 1
    Last Post: 08-01-2010, 12:20 PM
  2. Replies: 14
    Last Post: 06-03-2010, 06:03 PM
  3. Count of records
    By Aston in forum Access
    Replies: 2
    Last Post: 03-30-2010, 05:20 AM
  4. Count and Sum in Report
    By Brian62 in forum Reports
    Replies: 3
    Last Post: 02-19-2010, 04:10 PM
  5. error in count
    By humpz in forum Reports
    Replies: 6
    Last Post: 08-13-2009, 08:20 AM

Tags for this Thread

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