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
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.