0

I have a number of tables in an MS Access Db that have to use Replication IDs (GUID) as the primary key (and therefore also as foreign key contraints in the relationships between them). The data for these tables comes from an external application and I can't use any other field as a primary as they aren't unique. (I've also chosen, not to use local integer keys, "in loco parentis" for the GUID).

The database worked fine and all the relationships worked as expected and I am able to present the related records in a hierarchical MS Access form (one-to-many-to-many). The problem occurs when I try to present a count as part of the relationhips.

If I have GUIDInParent and GUID in Child as two fields, I can get the children by creating a form with Source Object = ParentToChildRelationship and Link Master Field = GUIDInParent and Link Child Field = GUIDInChild.

However, if I want indicate how many Chidren I'm going to display (since they may be hidden under a scrolled section), I use a separate form field populated via a DCount("1", "ParentToChildRelationship", "[GUIDinChild] = '" & [GUIDInParent] & '")

For the GUID field - this doesn't work... The reason appears to be that while on the form, the GUID (Replication ID) displays as a "GUID" - of the form "{HHHHHHH-HHHH-HHHH-HHHH-HHHHHHHHHHHH}" when assigned to another field it (literally) displays as "Chinese". Even assigning via the GUIDAsString function doesn't change this.

What's going on an is there any way I can use these GUIDs as I intend?

I have "jury rigged" a solution by having two columns in the tables (GUID - as number and GUIDString - as string) both set tot he same value and using the rendering that works in each case... The DCount("1", "ParentToChildRelationship", "[GUIDinChild] = '" & [GUIDInParent] & '") thus becomes: DCount("1", "ParentToChildRelationship", "[GUIDinChild] = '" & [GUIDInParentString] & '") and thus works...

TIA, Paolo

4

1 回答 1

0

您是否考虑过子表单页脚中的控件来计算记录?这可以在主窗体中按名称引用。或者,您可以参考MySubformControl.Form.Recordset.Recordcount

于 2012-06-03T11:06:18.117 回答