Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

query linked sql table field from access

Avatar of cskehan
cskehanFlag for United States of America asked on
Microsoft AccessMicrosoft SQL Server
4 Comments1 Solution101 ViewsLast Modified:
I am using access 365 and Sql Server 2014

I have two buttons, one to show all records in a linked sql table,the other, to perform a search for keywords in the same linked sql table.
The table is linked and connected using adodb.connection when the access database is opened. Please show me what changes I need to make for the desired results.

The code I am using is not producing the results I am looking for.
below is my code for each

To show all records in table

dim sql as string.

sql = "SELECT company.companyId, company.companyName, company.companyAddress, company.companyCity, company.companyState, company.companyZip, company.companyPhone, company.InCareOfName, company.Exclude, company.Keep, company.Reason, company.AccessNumber, company.Change " _
    & "FROM company " _
    & "ORDER BY company.companyName "
   
   
    Me.txtPltfkeywords = ""
    Me.companyList.Form.RecordSource = sql
    Me.companyList.Form.Requery

To search for keywords within the table

Dim sql As String

    sql = "SELECT company.companyID, company.companyName, company.InCareOfName, company.Exclude, company.Reason, company.companyPhone, company.companyAddress, company.companyCity, company.companyState, company.companyZip, company.Keep, company.AccessNumber, company.Change " _
& "FROM company " _
& "WHERE companyName Like ""*" & txtPltfkeywords & "*"" Or companyAddress Like ""*" & txtPltfkeywords & "*"" Or companyCity Like ""*" & txtPltfkeywords & "*"" Or Reason Like ""*" & txtPltfkeywords & "*"" Or companyState Like ""*" & txtPltfkeywords & "*"" Or companyZip Like ""*" & txtPltfkeywords & "*"" Or companyPhone Like ""*" & txtPltfkeywords & "*"" Or InCareOfName Like ""*" & txtPltfkeywords & "*""" _
& "ORDER BY company.companyName "
   
    Me.companyList.Form.RecordSource = sql
    Me.companyList.Form.Requery
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answers