Results 1 to 2 of 2
  1. #1
    DetrieZ is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    17

    Expected End Of Statement Dcount, Access 2003

    I am trying to set the rowsource of a LisBox



    This works in a query

    Code:
    SELECT TBLRECORDS.RecordsID, TBLRECORDS.FileID, DCount("RecordsID","TBLRECORDS","RecordsID <= " & [RecordsID]) AS Expr1, TBLRECORDS.Internal, TBLRECORDS.Processed
    FROM TBLRECORDS
    WHERE (((TBLRECORDS.FileID)="51"));
    but throws a Compile error expected end of statement at DCount("RecordsID" when I put it into a Dim'd statement

    Code:
    strLstOrders="SELECT TBLRECORDS.RecordsID, TBLRECORDS.FileID, DCount("RecordsID","TBLRECORDS","RecordsID <= " & [RecordsID]) AS Expr1, TBLRECORDS.Internal, TBLRECORDS.Processed From TBLRECORDS WHERE (((TBLRECORDS.FileID)="51"));"

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The double quotes within the DCount() need to be single quotes when inside the string built in code. If you think about it, the first set before the field name argument of the DCount() terminates the quotes begun before SELECT, leaving everything after twisting in the wind.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Can't get DCount statement to work
    By jhko in forum Programming
    Replies: 8
    Last Post: 02-10-2013, 05:50 AM
  2. Expected End of Statement error
    By SamNotSoWise in forum Programming
    Replies: 5
    Last Post: 06-25-2012, 04:41 PM
  3. problem with IF THEN statement in access 2003 query
    By sfgiantsdude in forum Access
    Replies: 4
    Last Post: 01-05-2012, 04:23 PM
  4. compile error: expected end of statement
    By RedGoneWILD in forum Programming
    Replies: 5
    Last Post: 07-29-2010, 10:12 AM
  5. Replies: 3
    Last Post: 07-21-2010, 02:41 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