Karen said:
Dirk,
OK, that I did not know. When I can't get something to work I go
back to the individual components to sort out the problem. Thanks so
much for that bit of info, who would have thunk!
I knew that, I just got confused when you asked for the code that
opened the form and when you mentioned the 'where' condition I
thought you meant the recordsource.
No, I was talking about the WhereCondition argument of the
DoCmd.OpenForm method. "WhereCondition" is the actual name of the
argument where you pass a filter-string such as "ContactID=1" -- where
the stLinkCriteria variable is passed in code written by the Command
Button Wizard.
Are we
It really is a subform. It is a tabbed form, the first tab has fields
related directly to the tabbed form's recordsource and I dragged the
'contacts' form to the second tab.
Okay, good.
Yes, that is exactly it. The contacts do display correctly, i.e. the
first tab is the info related to a company and the contacts tab only
has the contacts associated with that company. I was frustrated
because I'd like to add new contacts from the contacts tab but I
can't get the asterisk (*) 'new' navigator button to be active. At
this point I think I'll just have to use a command button to open a
separate form to add new contacts.
Oh, no, not at all. I believe the problem is quite simple, and it's
just as John Vinson and I were both suggesting might be the case before
we went off on this wild goose chase over filtering. Your "new record"
button is disabled, and your contacts are uneditable, because your
subform's recordsource query is not updatable. It is not that
multi-table queries are inherently nonupdatable, it's just that your
query incorrectly includes the TestCompanyMain table, thereby creating a
many-to-one-to-many relationship within the query. You don't need any
fields from TestCompanyMain, because they're already there on the main
form, and adding this table creates a nonupdatable query.
Try this as your recordsource query:
SELECT DISTINCT
TestCompanyContactLinkTable.ccCompanyID,
TestCompanyContactLinkTable.ccContactID,
TestContactTable.*
FROM TestContactTable
INNER JOIN TestCompanyContactLinkTable
ON TestContactTable.ContactID =
TestCompanyContactLinkTable.ccContactID;
On the property sheet of the subform control on the main form, set the
Link Master Fields property to CompanyID -- I assume that's the name of
the primary key field of TestCompanyMain -- and set the Link Child
Fields property to ccCompanyID (*not* the CompanyID field from
TestContactTable). That will automatically take care of filtering the
subform so that it only shows the contacts related to the current
company on the main form. You don't need any WHERE clause in the above
recordsource query, because Access's normal handling of the subform will
take care of that.
I won't go so far as to guarantee that making these changes will make
the form and subform work right off the bat, but I'll guarantee that
doing it will put us within striking distance. Unless there's something
else you haven't told us ... ;-)
Again, thanks for the patience. I'm still a very green Access person
but it's so much fun it's hard to stop.
Ain't it, though?