I want to check for existing records on my subform. The problem is that my form is based on an intersection table.
Table 1
CompanyID
CompanyName
Contact
Table 2
OpportunityID
OpportunityName
Description
Intersection Table
CompanyID
OpportunityID
What I have done is that I have a form based on Table 2. On that form I placed a subform to see all the companies related to that Opportunity. So I created a query with fields OpportunityID, CompanyID, CompanyName and Contact and based my subform on this query. I want to check for existing records on this subform. I saw the code somewhere to check for existing record.
I tried this
If DCount("[CompanyID]", "tblIntersection", "[CompanyID] = " & Me![CompanyID] & "") > 0
But this does not work. I think I need to check for both OpportunityID and CompanyID to check for existing record. I can't figure out how to do this.
I really need to get this done. I would appreciate any help.
Thanx
Ekta
Table 1
CompanyID
CompanyName
Contact
Table 2
OpportunityID
OpportunityName
Description
Intersection Table
CompanyID
OpportunityID
What I have done is that I have a form based on Table 2. On that form I placed a subform to see all the companies related to that Opportunity. So I created a query with fields OpportunityID, CompanyID, CompanyName and Contact and based my subform on this query. I want to check for existing records on this subform. I saw the code somewhere to check for existing record.
I tried this
If DCount("[CompanyID]", "tblIntersection", "[CompanyID] = " & Me![CompanyID] & "") > 0
But this does not work. I think I need to check for both OpportunityID and CompanyID to check for existing record. I can't figure out how to do this.
I really need to get this done. I would appreciate any help.
Thanx
Ekta