Hello again,
My wife asked me to create her a database to keep track of all her quilting books and magazines. I've pretty well completed the database, but I'm stuck on an issue with searching. So, there are 2 tables as follows:
tblQuiltMags:
FormID - Autonumber (Primary Key)
QuiltID - Number
Title - Short Text
Publisher - Short Text
Volume - Number
Issue - Number
tblQuiltMagsTopics:
ProjectID - Autonumber (Primary Key)
BookID - Number
Topic - Short Text
PageNo - Number
BlockName - Short Text
ProjectLink - HyperLink
ProjectVideo - HyperLink
I have a form with a subform for search results, called frmSearchResults. There is a 1 to many relationship between tblQuiltMags.FormID and tblQuiltMagsTopics.BookID. I have created 2 queries that are linked to the form. qrySearchMagsContentMain is the RecordSource for the main form (frmSearchResults), and qrySearchMagsContentSub is the RecordSource for its subform. On the subform, I have set the LinkMasterFields to FormID and LinkChildFields to BookID. When I click the search button, another small form opens up, called frmSearch, and the keywords are entered into a text box called txtKeyWords.
The SQL for each query is as follows.
qrySearchMagsContentMain:
SELECT tblQuiltMags.FormID, tblQuiltMags.QuiltID, tblQuiltMags.Title, tblQuiltMags.Publisher, tblQuiltMags.Volume, tblQuiltMags.Issue, tblQuiltMagsTopics.ProjectID, tblQuiltMagsTopics.Topic, tblQuiltMagsTopics.PageNo, tblQuiltMagsTopics.BlockName, tblQuiltMagsTopics.ProjectLink, tblQuiltMagsTopics.ProjectVideo
FROM tblQuiltMags INNER JOIN tblQuiltMagsTopics ON tblQuiltMags.FormID = tblQuiltMagsTopics.BookID
WHERE (((tblQuiltMagsTopics.Topic) Like "*" & [Forms]![frmSearch].[txtKeyWords] & "*"));
qrySearchMagsContentSub :
SELECT tblQuiltMagsTopics.BookID, tblQuiltMagsTopics.ProjectID, tblQuiltMagsTopics.Topic, tblQuiltMagsTopics.PageNo, tblQuiltMagsTopics.BlockName, tblQuiltMagsTopics.ProjectLink, tblQuiltMagsTopics.ProjectVideo
FROM tblQuiltMagsTopics
WHERE (((tblQuiltMagsTopics.BookID)=[Forms]![frmSearchResults]![FormID]) AND ((tblQuiltMagsTopics.Topic) Like "*" & [Forms]![frmSearch].[txtKeyWords] & "*"));
My problem is this. I want to be able to type in a keyword and search tblQuiltMagsTopics.Topic for that keyword, and see the results on the form. It works ok, but every time there's more than one topic in the same magazine, it shows one for each in the main form. For example, if I search for the word "block" and one magazine has 3 topics with the word block, then it will give 3 records. But all 3 will show the exact same thing, because I still see those 3 records in the subform of each main record. Is there any way to set this up so that I will only get one record on the main form, and all results on the subform for that keyword, without having duplicate records on the main. Any help would be appreciated.
Hope this makes sense. Thank you.