hi Tony,
I'm sorry to be so pedantic but could I just return to what I'm trying to do.
I have a form that has a control for a company name (txtcompany) It has a
[quoted text clipped - 7 lines]
1 not consecutive from the previous month. This why I can't see how using the
ID will do this.
But I am not an experienced Access programmer so maybe I'm missing something fundamental here?
No, I don't think so. Take a closer look at the logic in the simple
example. The record number is built on an (artifical) order given
through the criteria in the DCount() statement. You have now to build a
criteria which expresses exactly your needs. Using a simplified table
structure:
Company:
[ID], AutoNumber, Primary Key
[Name] Text(255) Not Null
Deal:
[ID], AutoNumber, Primary Key
[idCompany], Number Not Null, Foreign Key to table Company
[Date] DateTime Not Null
[Comment] Memo
Then you need for your sub-form this SQL as record source:
SELECT
*,
DCount(
"*",
"[Deal]",
"[idCompany] = " & [idCompany] &
" AND [Date] <= " & [Date] &
" AND Year([Date]) = " & Year([Date]) &
" AND Month([Date]) = " & Month([Date])
) AS [RecNo]
FROM [Deal]
mfG
--> stefan <--