Results 1 to 3 of 3
  1. #1
    Jo.. is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jun 2015
    Posts
    32

    How to add counter to StrSQL vba?

    I am trying to add DCount Expression to my query. But it does not seem to be working. Please help!!!



    The Code I am trying to use:
    Code:
    MyRS = MyDB.OpenRecordset("SELECT *, DCount("[ProductDescription]", "[myQQQuery]", "[ProductDescription] <='" & [ProductDescription] & "'") AS RowNum FROM myQQQuery;", dbOpenSnapshot)
    How to convert it?

  2. #2
    JamesDeckert is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    Salina, KS
    Posts
    262
    Dcount doesn't put the query name in square brackets in any of the reference that I see.
    http://www.techonthenet.com/access/f...ain/dcount.php
    https://msdn.microsoft.com/en-us/lib...or=-2147217396

    try
    MyRS = MyDB.OpenRecordset("SELECT *, DCount("[ProductDescription]", "myQQQuery", "[ProductDescription] <='" & [ProductDescription] & "'") AS RowNum FROM myQQQuery;", dbOpenSnapshot)

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by Jo.. View Post
    ...
    How to convert it?
    What are you trying to build, a query Object? It seems what you have there is a DAO recordset. The recordset uses the variable, "[ProductDescription]". So, if you are building a query object, you will have to pass the value to the query object.

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

Similar Threads

  1. Replies: 4
    Last Post: 12-21-2013, 11:03 PM
  2. Understanding recordsets strsql
    By Ruegen in forum Programming
    Replies: 15
    Last Post: 11-24-2013, 07:08 PM
  3. VBA strSQL mismatch
    By SPW_12 in forum Programming
    Replies: 12
    Last Post: 07-31-2012, 07:47 PM
  4. Need to add 2nd criteria to strSQL
    By robsworld78 in forum Forms
    Replies: 8
    Last Post: 08-23-2011, 02:57 PM
  5. DLookup in strSQL for OpenRecordset
    By szucker1 in forum Programming
    Replies: 2
    Last Post: 07-30-2011, 06:00 PM

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