Hi,
I have been working through this problem for a while and I have been looking through these forums for an answer and couldn't find one, so I thought I would post it:
I have a database with a list of people in it. In the main form, I have a subform for previous names (A woman who gets married 5 times will have 6 different last names and I don't want 6 different fields on my main form, so I use a subform for previous last names).
I currently have a separate form to search my main form using a filter (here is the code):
DoCmd.OpenForm "People_List",acNormal,"",[LastName] like '*" & Search_Last_Name & "*'"
Now this works great if I am searching the main form for a person's last name. I can type in whatever I want into the Search_Last_Name field, click search, and it brings up everyone with a CURRENT last name matching my text. However - I want to be able to search the subform "Other_Last_Names" at the same time, and show the main form.
For example: 2 records:
1. Jane Smith (Former last name Henry)
2. Jill Henry (No former last names)
So when I search for Henry, it should bring up Jane Smith's record, as well as Jill Henry's record.
Does anyone have any suggestions? I am really stumped on this one. I know how to do a search box on a form to accomplish this with the following code:
Me.RecordSource = "SELECT [People_List].* FROM [People_List] INNER JOIN [Other_Last_Names] ON [People_List].[ID] = [Other_Last_Names].[ID] WHERE [Other_Last_Names].[FormerName] LIKE '*" & txtFind & "*' OR [People_List].[LastName] like '*" & txtFind & "*'"
This will work if I have a textBox and search button on my main form, but the project specifies using a separate search form to search for records.
Can this be accomplished? Does anyone have advice? Any help would be much appreciated!! Thank you so much in advance!
Brian
I have been working through this problem for a while and I have been looking through these forums for an answer and couldn't find one, so I thought I would post it:
I have a database with a list of people in it. In the main form, I have a subform for previous names (A woman who gets married 5 times will have 6 different last names and I don't want 6 different fields on my main form, so I use a subform for previous last names).
I currently have a separate form to search my main form using a filter (here is the code):
DoCmd.OpenForm "People_List",acNormal,"",[LastName] like '*" & Search_Last_Name & "*'"
Now this works great if I am searching the main form for a person's last name. I can type in whatever I want into the Search_Last_Name field, click search, and it brings up everyone with a CURRENT last name matching my text. However - I want to be able to search the subform "Other_Last_Names" at the same time, and show the main form.
For example: 2 records:
1. Jane Smith (Former last name Henry)
2. Jill Henry (No former last names)
So when I search for Henry, it should bring up Jane Smith's record, as well as Jill Henry's record.
Does anyone have any suggestions? I am really stumped on this one. I know how to do a search box on a form to accomplish this with the following code:
Me.RecordSource = "SELECT [People_List].* FROM [People_List] INNER JOIN [Other_Last_Names] ON [People_List].[ID] = [Other_Last_Names].[ID] WHERE [Other_Last_Names].[FormerName] LIKE '*" & txtFind & "*' OR [People_List].[LastName] like '*" & txtFind & "*'"
This will work if I have a textBox and search button on my main form, but the project specifies using a separate search form to search for records.
Can this be accomplished? Does anyone have advice? Any help would be much appreciated!! Thank you so much in advance!
Brian