P
Peter Hallett
I have a table, listing sales in date order. Each transaction is identified
by its associated account number. A separate table relates the account
numbers to the corresponding customer IDs. The reason for the indirect
linkage is that although most accounts are individually held – ie associated
with a unique ID – several are shared between two, and sometimes three or
four, customers. In other words, the ID/Account No. relationship is
one-many. The associated table has two columns. When an account is added, a
new record is created, showing the new ID and the associated account number.
If an existing account is to be shared, the new account number field will be
the same as that of an existing account listed elsewhere in the table.
Clearly, there is no limit to the number of records that can be added to the
table or the number that can be associated with any given account.
A report is required which lists transactions effected between manually
selected start and end dates, entered on a form. There is no difficulty in
writing a query or SQL statement to produce the required list of
transactions, sorted by account number, within the required date range, but
this is of limited use. More important is to show the account holders by
name. This means using the ID/Account No. table to find the ID(s) associated
with each account number. However, if this table is included in any query or
SQL statement, used as the basis of a report, the associated transactions are
duplicated for each contributing ID. For example, if three customers share
an account, the transaction list is shown three times, leading not only to
confusion but to incorrect report totals.
The immediate thought was that the unwanted duplication could be eliminated
by basing the report on queries utilizing the unique record or unique value
property but this has proved impossible. The ID/Account No. table, being
one-many, contains numerous duplicate account numbers. It is not difficult
to eliminate these by means of a suitable select query using the unique value
property but, immediately the ID field is included in the query, the
duplicate account numbers – and hence the associated duplicate transaction
records – all reappear in the output. I have had to admit defeat on this
one. Anyone got any bright ideas?
by its associated account number. A separate table relates the account
numbers to the corresponding customer IDs. The reason for the indirect
linkage is that although most accounts are individually held – ie associated
with a unique ID – several are shared between two, and sometimes three or
four, customers. In other words, the ID/Account No. relationship is
one-many. The associated table has two columns. When an account is added, a
new record is created, showing the new ID and the associated account number.
If an existing account is to be shared, the new account number field will be
the same as that of an existing account listed elsewhere in the table.
Clearly, there is no limit to the number of records that can be added to the
table or the number that can be associated with any given account.
A report is required which lists transactions effected between manually
selected start and end dates, entered on a form. There is no difficulty in
writing a query or SQL statement to produce the required list of
transactions, sorted by account number, within the required date range, but
this is of limited use. More important is to show the account holders by
name. This means using the ID/Account No. table to find the ID(s) associated
with each account number. However, if this table is included in any query or
SQL statement, used as the basis of a report, the associated transactions are
duplicated for each contributing ID. For example, if three customers share
an account, the transaction list is shown three times, leading not only to
confusion but to incorrect report totals.
The immediate thought was that the unwanted duplication could be eliminated
by basing the report on queries utilizing the unique record or unique value
property but this has proved impossible. The ID/Account No. table, being
one-many, contains numerous duplicate account numbers. It is not difficult
to eliminate these by means of a suitable select query using the unique value
property but, immediately the ID field is included in the query, the
duplicate account numbers – and hence the associated duplicate transaction
records – all reappear in the output. I have had to admit defeat on this
one. Anyone got any bright ideas?