To run a dynamic query under dcount,
the sql filter query should be written as smig stated
qrycounter = DCount("[Logid]", "tbllog", "[tbllog].[sitesid] = " & [forms]![frmsites]![sitesid] & " ")
or (if sitesid is a textfield)
qrycounter = DCount("[Logid]", "tbllog", "[tbllog].[sitesid] = '"...