DS said:
Thanks Dirk. That looks good. One problem though just came up. I'm
using a regular DCount to get the records from the current db. And your
code to get the records from the other db containing the records that are
over one year old. But, what do I do when I have to get get records from
both db's and consolidate it down to one answer?
Can you just add the result of the local DCount to the result of the
external database query? That would seem simplest, but maybe I don't
understand what you're after.
If you need to, I think you could use a UNION query that merges selected
records from the external DB with records from the local DB, and counts the
resuting records. Something like this, maybe:
'---- EXAMPLE ONLY! I DON'T KNOW ENOUGH ----
Set rs = CurrentDb.OpenRecordset( _
"SELECT Count(*) FROM (" & _
"SELECT ChkFXSep FROM " & _
"[MS Access;Database=\\Backoffice\Warehouse\History.mdb]" & _
".tblChecks " & _
"WHERE ChkFXSep = -1 And ChkServer = " & Me.TxtServerID & _
" And ChkBizDay BETWEEN " & _
Format(Forms!frmReportDates!TxtStart, "\#yyyy\-mm\-dd\#") & _
" AND " & _
Format(Forms!frmReportDates!TxtEnd, "\#yyyy\-mm\-dd\#") & _
" UNION ALL " & _
"SELECT ChkFXSep FROM tblChecks " & _
"WHERE ChkFXSep = -1 And ChkServer = " & Me.TxtServerID & _
" And ChkBizDay BETWEEN " & _
Format(Forms!frmReportDates!TxtStart, "\#yyyy\-mm\-dd\#") & _
" AND " & _
Format(Forms!frmReportDates!TxtEnd, "\#yyyy\-mm\-dd\#") & _
")", _
dbOpenSnapshot)
'---- END EXAMPLE ----
That's assuming that the table is named "tblChecks" in both databases, and
you want to count records meeting the same criteria from both tables.