Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2016
    Posts
    11
    Provided Answers: 1

    Answered: Access DCount giving Runtime 3078 error

    Hi everyone,

    I'm just learning how to use Access, so this might be quite a simple fix, although nothing I've found online has helped yet.

    I'm to create some metadata held during a vba script (and then discarded) to be used for calculations which'll go in a table. The first (and simplest one) is meant to just be a count of the number of records in an input data table. Here is the relevant script I have so far:

    Dim var_num As Integer
    Set rec_source_data = db.OpenRecordset("select * from TBL_DATA_Combined order by ID_Number")
    var_num = DCount("ID_Number", "rec_source_data")

    Before I put in the DCount, the rest of the script was working fine, and to check that nothing else was tripping up the DCount, I positioned it right after the Set rec_source_data line. I've tried defining var_num as a double and single too (though it should of course be an integer), no luck, and initially the DCount was meant to be filtered, so it looked like this

    var_num = DCount("ID_Number", "rec_source_data", "Filter = True")

    Nothing I've found online suggests I have the wrong syntax, but whatever I do (including rebooting my laptop), I keep getting Run time error 3078 - that the db can't find the input table rec_source_data.

    Any suggestions? Thanks in advance

  2. Best Answer
    Posted by myle

    "NEVER Seen Dcount used on a recordset like u did

    Set rec_source_data = db.OpenRecordset("select * from TBL_DATA_Combined order by ID_Number")
    var_num = DCount("ID_Number", "rec_source_data")

    my under standing is

    aaa= DCount("CountThisFeild","TableName","Crit")

    so

    this should work

    var_num = DCount("*", "TBL_DATA_Combined")"


  3. #2
    Join Date
    Nov 2016
    Posts
    11
    Provided Answers: 1

    Update

    So, I've tried out using a RecordCount, and bizarrely this worked, despite the previous error message saying it couldn't find a table called rec_source_data. I used:

    var_num = rec_source_data.RecordCount

    and displayed the value in a MessageBox. No problem there, so it's definitely something strange with DCount and Count (I forgot to mention, but I tried Count too, and Access gave me a Compile Error message - "Wrong number of arguments or invalid property assignment".

    I still need to be able to filter the records being counted, so I can't stick to RecordCount unfortunately. Either I need to work out what's wrong with the DCount function or find a way to filter a Record Count.

    Not sure this is helpful, but I'm using Access 2013.

  4. #3
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,424
    Provided Answers: 8
    NEVER Seen Dcount used on a recordset like u did

    Set rec_source_data = db.OpenRecordset("select * from TBL_DATA_Combined order by ID_Number")
    var_num = DCount("ID_Number", "rec_source_data")

    my under standing is

    aaa= DCount("CountThisFeild","TableName","Crit")

    so

    this should work

    var_num = DCount("*", "TBL_DATA_Combined")
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

  5. #4
    Join Date
    Nov 2016
    Posts
    11
    Provided Answers: 1
    Haha, well I have a knack for finding weird and new ways to do things!

    Thank you though, that worked perfectly - at least by asking it on the forum, the solution (if anyone else ever tries to do it) is out there

Posting Permissions

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