简体   繁体   中英

MS Access 2010 Filter re-usable subform, based on parent field

Parent form has a textbox containing an ID

Subform (child form) is a multiform containing the ID's of things linked to the parent ID (and others)

Many different parent forms use the same subform (child form), which means the usual method of:

WHERE [Child_IDs]=[Forms]![ParentFormName]![ID_TextBox]

doesn't work directly, as once saved it overwrites the filters for the other parent forms (breaking them).

Whilst searching for a solution, everybody has been saying to use:

Me.Parent![ID_TextBox]

or

Parent![ID_TextBox]

to resolve the problem, yet when I try using them in the expression builder, it fails to find either Me or Parent . Aka does not work.

I'm also trying to keep this setup flexible enough to deal with multiple instances of the parent forms as well.

Am I going down the right track? Any suggestions on what I should do?


DETAILED VERSION OF WHAT I'M DOING

I'm trying to create a small requirements database to help me with a few projects I'm working on.

The record specific (parent) info is fine, as are most of the relationships as they're specific enough to directly link via Link Master/Child Fields .

The problem children are "Comments", "References" and "Tags", which link to EVERY type of record (even themselves, for simplicities sake).

I've created a query which unions all of the ID's of each table together, whilst putting them into a "standard" format LLL000000 , where LLL is a three letter acronym (TLA) for the table.

Even if I separated the LLL out from the records, I'm still stuck because that TLA isn't referenced in the bounded parent form. If I could reference the parent directly and ask for its ID_TextBox field, I'd be fine. If I didn't have to reuse the same subform for multiple parent forms, I'd be fine.

Multiple form instances crop up with the "grandparent" form, which will (hopefully) view (at most) 2 of the parent forms simultaneously, including 2 of the same type.

I'm deliberately leaving the multiple instances till last as that's a headache I'd like to leave when the incentive equals instant completion afterwards (I've not been having fun with VBA either).

I ended up adding a new field to all of the "main" tables which redundantly adds the three letter acronym to each record by default.

Since it's there I can reference it in the Master/Child Links section along with the ID (effectively reconstructing the LLL000000 ID, but needing to add more hard-coded values into the system and waste memory space...)

This is not an ideal solution as it just increases the maintenance overhead. (Not as much as some of the other solutions I thought of, but still).

As such, I won't mark this as the answer and instead, wait for other suggestions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM