Thank you Piet! Much clearer explanation!!!
--
Gina Whipp
"I feel I have been denied critical, need to know, information!" - Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
So, in words, you want me to create a third table, that lists each
employee
as many times as he/she has invoices, and will end up listing each invoice
for as many employees as it has associated with it.
And then concatenate (thanks very much! Hadn't thought of that).
1.) Is there some reason a simple query wouldn't suffice? Do I need to
actually have a third table, as opposed to query?
2.) I can't seem to get the code to work as a module - triple checked the
field / table names several times, and as they are text, switched in the
bit
with the quotes mentioned in the third argument. If I wanted the
concatenated
data (as text or as a multi value field, either way) to be a field in a
table
or a query, where would I put the code?
- Show quoted text -
JJ,
Maybe this will help (I hope!). Let me start in plain old English,
because this part is confusing for beginners...
Your basic "rules" are:
1. MANY Employees can be related to MANY Invoices.
2. MANY Invoices can be related to MANY Employees.
If both statements are true, then you have to have a join table,
because you have a many-to-many relationship. The problem is Access
can't work with many-to-many relationships, so you break the
relationships in half (create two one-to-many relationships for each
many-to-many). So.
Employee---(1,M)---EmployeeInvoice--------(M,1)--------Invoice
CREATE TABLE Employee (
EmployeeID INTEGER PRIMARY KEY,
FirstName TEXT(20),
....)
CREATE TABLE Invoice (
InvoiceNo INTEGER PRIMARY KEY,
InvoiceDate DATE,
....)
CREATE TABLE Employee_Invoice (
eiEmployeeID INTEGER,
eiInvoiceNo INTEGER,
PRIMARY KEY (eiEmployeeID, eiInvoiceNo),
FOREIGN KEY eiEmployeeID REFERENCES Employee(EmployeeID),
eiInvoiceNo REFERENCES Invoice(InvoiceNo));
Employee-Invoice stores the information about which invoices belong to
which employees (one record for each instance of "belongs to"). Then
once you have this setup, you can use Allen's function to concatenate
the Invoice Numbers, so you get
(Employee, ListOfInvoices...) where ListOfInvoices is a concatenated
string. (e.g. "Inv01, Inv03, Inv04")
Hope this helps.