Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003
    Posts
    268

    Unanswered: Return Record Count

    I want to create something similar to DLookup in VBA. Given a select string the method should return the value (type Variant), be it an integer, a string, a double etc.

    I am using DAO but am getting an error in one of my test examples.

    the SQL is SELECT Count(Object) as ObjectCount FROM Object

    When trying to pass this string into to
    rs.open(sql)

    I get (pasted from the debugger window)
    ?err.Number
    -2147217900
    ?err.Description
    Syntax error in FROM clause.

    When I paste that SQL string into a QBE window everything works fine.

    Anyone have any ideas?

    MW

    p.s. I know I can do this with DLookup, but I don't want to. I need to make sure the code is migratable to any platform (Java, .NET) and don't want to rely on VB specific calls.

  2. #2
    Join Date
    Jun 2004
    Location
    Florida, US
    Posts
    521
    did you try DCount() ?
    Edit: please ignore my answer. I didn't see your footnote.
    ghozy.

  3. #3
    Join Date
    Jun 2004
    Location
    Florida, US
    Posts
    521
    try to take your field and table names into brackets.
    SELECT Count([Object]) as ObjectCount FROM [Object];
    I believe Object is a reserved keyword in VB.
    ghozy.

Posting Permissions

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