alfonsomozo
Technical User
I have two tables. One is a list of contacts named "Contacts" and the other is a record of the seminars attended by each contact "Seminars" which is linked to by the ContactID of the Contacts table. So there is one record for each contact but each contact may attend a number of different seminars. The seminars table has a SeminarID, ContactID, Seminar, Seminar Date, Notes.
I have search functionality which shows the results of the search in a continuous form showing each field of the contacts table and the seminars table. This is all working as i would like unless a Contact has attended more than one seminar.
If a contact has attended more than one seminar then there will be a record returned for each seminar. One With all the contact details and then the Seminar details of one seminar and then another with the same contact details except with the details of a different seminar.
Is there anyway in which i can have the search results only show the contact details once but then have all the seminar details for that one contactID. Kind of like as shown below.
ContactID FirstName LastName Email Seminar1 Seminar1date
Seminar2 Seminar2date
SeminarN SeminarNdate
The data is also going to be exported as an rtf for use in a mail merge so it is important not to duplicate contact details.
Here is the SQL for my search query
thanks for looking.
I have search functionality which shows the results of the search in a continuous form showing each field of the contacts table and the seminars table. This is all working as i would like unless a Contact has attended more than one seminar.
If a contact has attended more than one seminar then there will be a record returned for each seminar. One With all the contact details and then the Seminar details of one seminar and then another with the same contact details except with the details of a different seminar.
Is there anyway in which i can have the search results only show the contact details once but then have all the seminar details for that one contactID. Kind of like as shown below.
ContactID FirstName LastName Email Seminar1 Seminar1date
Seminar2 Seminar2date
SeminarN SeminarNdate
The data is also going to be exported as an rtf for use in a mail merge so it is important not to duplicate contact details.
Here is the SQL for my search query
Code:
SELECT Contacts.ContactID, Contacts.SalutationID, Contacts.FirstName, Contacts.LastName, Contacts.Address1, Contacts.Address2, Contacts.City, Contacts.StateID, Contacts.PostalCode, Contacts.CompanyName, Contacts.Position, Contacts.WorkPhone, Contacts.WorkExtension, Contacts.MobilePhone, Contacts.FaxNumber, Contacts.EmailName, Contacts.ContactTypeID, Contacts.Notes, Contacts.[Authorised By], Contacts.[Authorised Date], Seminars.Seminar, Seminars.[Seminar Date], Seminars.Notes
FROM Contacts LEFT JOIN Seminars ON Contacts.ContactID = Seminars.ContactID
WHERE (Contacts.SalutationID Like '*' & [Forms]![Search]![Salutation] & '*' OR [Forms]![Search]![Salutation] Is Null)
AND (Contacts.FirstName Like '*' & [Forms]![Search]![FirstName] & '*' OR [Forms]![Search]![FirstName] Is Null)
AND (Contacts.LastName Like '*' & [Forms]![Search]![LastName] & '*' OR [Forms]![Search]![LastName] Is Null)
AND (Contacts.Address1 Like '*' & [Forms]![Search]![Address] & '*' OR [Forms]![Search]![Address] Is Null)
AND (Contacts.Address2 Like '*' & [Forms]![Search]![Address2] & '*' OR [Forms]![Search]![Address2] Is Null)
AND (Contacts.City Like '*' & [Forms]![Search]![City] & '*' OR [Forms]![Search]![City] Is Null)
AND (Contacts.StateID Like '*' & [Forms]![Search]![State] & '*' OR [Forms]![Search]![State] Is Null)
AND (Contacts.PostalCode Like '*' & [Forms]![Search]![PostalCode] & '*' OR [Forms]![Search]![PostalCode] Is Null)
AND (Contacts.CompanyName Like '*' & [Forms]![Search]![CompanyName] & '*' OR [Forms]![Search]![CompanyName] Is Null)
AND (Contacts.Position Like '*' & [Forms]![Search]![Title] & '*' OR [Forms]![Search]![Title] Is Null)
AND (Contacts.WorkPhone Like '*' & [Forms]![Search]![WorkPhone] & '*' OR [Forms]![Search]![WorkPhone] Is Null)
AND (Contacts.WorkExtension Like '*' & [Forms]![Search]![WorkExtension] & '*' OR [Forms]![Search]![WorkExtension] Is Null)
AND (Contacts.MobilePhone Like '*' & [Forms]![Search]![MobilePhone] & '*' OR [Forms]![Search]![MobilePhone] Is Null)
AND (Contacts.FaxNumber Like '*' & [Forms]![Search]![FaxNumber] & '*' OR [Forms]![Search]![FaxNumber] Is Null)
AND (Contacts.EmailName Like '*' & [Forms]![Search]![EmailName] & '*' OR [Forms]![Search]![EmailName] Is Null)
AND (Contacts.ContactTypeID Like '*' & [Forms]![Search]![ContactTypeID] & '*' OR [Forms]![Search]![ContactTypeID] Is Null)
AND (Contacts.Notes Like '*' & [Forms]![Search]![Notes] & '*' OR [Forms]![Search]![Notes] Is Null)
AND (Contacts.[Authorised By] Like '*' & [Forms]![Search]![Authoriser] & '*' OR [Forms]![Search]![Authoriser] Is Null)
AND (Contacts.[Authorised Date] Like '*' & [Forms]![Search]![Authorised Date] & '*' OR [Forms]![Search]![Authorised Date] Is Null)
AND (Seminars.Seminar Like '*' & [Forms]![Search]![seminar] & '*' OR [Forms]![Search]![seminar] Is Null)
AND (Seminars.[Seminar Date] Like '*' & [Forms]![Search]![semdate] & '*' OR [Forms]![Search]![semdate] Is Null)
AND (Seminars.Notes Like '*' & [Forms]![Search]![semnotes] & '*' OR [Forms]![Search]![semnotes] Is Null);
thanks for looking.