473,387 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Search on Multiple tables

Split from thread:
http://bytes.com/topic/access/answer...do#post3790250

1 - How do I search more than one table in a keyword search? (I know I need a join or a UNION but I'm not sure how to implement it)

Essentially I have this code to search a set of tables:
Expand|Select|Wrap|Line Numbers
  1. Private Sub btnSearch1_Click()
  2.    On Error GoTo problem
  3.    Dim strsearch As String
  4.    Dim strText As String
  5. '
  6.    strText = Me.TxtSearch1.Value
  7.    strsearch = "SELECT * " & _
  8.       "FROM [tblCompany] " & _
  9.       "WHERE (([Company_name] LIKE ""*" & _
  10.          strText & "*"") OR(Quote_Type LIKE ""*" & _
  11.          strText & "*""))"
  12.    Me.RecordSource = strsearch
  13. '  
  14. End Sub
  15.  

And I'm wondering how do I incorporate a UNION to add a second table to the search? The 2nd table I want to search is tblContact
Apr 21 '15 #1
4 1638
zmbd
5,501 Expert Mod 4TB
You may not need a union.
Without your table structure and relationships it will be difficult to provide any guidance.
-z
Apr 21 '15 #2
My table structure is relatively simple.

there are three tables - tblCompany, tblSupplier and tblContact.

tblSupplier contains five fields "Company_ID", "Contact_ID", Order, Price and ID. The first two fields are linked to tblContact and tblCompany.

tblCompany has 3 fields - ID, Company_Name, Quote_Type
tblContact has 7 fields - CompanyID, First_Name, Second Name, title, email, phone, address.

Connections
ID field in tblCompany is connected to Company_ID in tblSupplier

Company_ID field in tblContact is connected to Contact_ID in tblSupplier
Apr 21 '15 #3
I have attached an image of the relationships here

Attached Images
File Type: jpg relationships_supplier.jpg (18.7 KB, 288 views)
Apr 21 '15 #4
zmbd
5,501 Expert Mod 4TB
To be totally honest with you here, reading all of the threads, looking at what you have here... I'm Guessing at what you are actually after.

So from what it looks like to me, how I would handle this would be:
Two combboxes
One with recordsource to your tblCompany
One with recordsource to your tblContacts

Both CboBox set to show friendly name and return the primary key.
Now use the values of the the CboBoxes to search against tblSupplier building your string as needed... something along the filtering and cascade-CboBox articles:
Apr 21 '15 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Gobi | last post by:
Hello, I have a Database with lists of Clients in each. Every year a new tables is created with the naming convention "CloseYear" ie close1999, close2000 There are tables from this year back to...
1
by: Brian | last post by:
I'm trying to find a way to search multiple tables for the same record. Say I have 3 tables all with a name column, I need to search all 3 tables and find matching names. Is there an easy way to...
3
by: Katrina | last post by:
I am trying to write a piece of code that will search through a number of different tables (current one being tableNm) to look for a specific street name that has been entered by the user and saved...
0
by: SamKhazary | last post by:
I have created a database that has a main table with a description of different products. I have 5 other data bases that are linked sheets that have returns for the 5 different prduct groups. I'd...
3
by: divina11 | last post by:
How do I go through Multiple tables (tables 1-20) to search for a particular word e.g. "first" and then print the results (i.e. table name & column name which contains the word "first"). Not sure...
0
by: redpears007 | last post by:
Morning all! :) I have a database with multiple linked tables. I have created a search form with one txt box, for entering search criteria, and a listbox for each of the tables to isplay the...
2
by: deiv82 | last post by:
Hello everyone, I'm trying to do a little search engine for my website. Like often, I've the problem to operate on multiple tables. This is the part of code that interests my problem. It works...
1
by: Lyn DeMaio | last post by:
I've been tasked with taking two unrealted tables (Providers and Patients, no common field) and allow users, on one form (or form/subform) to search multiple fields in each table, select a record...
1
by: meisjen86 | last post by:
Hey guys, I'm working on a project from school. I want to be able to search for a term across multiple tables in a database. For ex. I have two tables(table a, table b) set up the exact same...
2
by: SKumar365 | last post by:
Hi, I have a database with multiple tables,( Tables are payroll data named as Jan'11, Feb'11 etc up to Dec'11). I would like to have a combo box in the form to show these tables, and a text box to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.