sql embedded in vba

exaccess

Registered User.
Local time
Today, 18:40
Joined
Apr 21, 2013
Messages
287
I can not get the following SQL query to work. Help please.

Code:
         RowSQL = "SELECT [Telephone].[TelefID], [Telephone].[FIRST], [Telephone].[LAST], [Telephone].[ADDRES], * "  & _
                "FROM [Tables].[Telephone] " & _
                "WHERE [Telephone].[FIRST] Like ""&%Sozcuk=%&"";"
 
create the query as required in the query builder and compare with what you have.

Some general comments

First and Last are reserved words so can cause problems, recommend you change them

Remove the
. in your FROM statement
 
Also note that the wildcard character used in Like comparisons is * in Access rather than % as used in some other databses.
 
Gentlemen,
I have taken all your advice into account, copied structure and data to an empty table with a slightly different name and field names. Here is the result a working query:
Code:
RowSQL = "SELECT [TelephoneAAA].[TelefID], TelephoneAAA.ADI, TelephoneAAA.SOYADI, TelephoneAAA.ADRES, * " & _
                "FROM [TelephoneAAA] " & _
                "WHERE (((TelephoneAAA.ADI) Like ('*')+[Sozcuk]+('*'))) OR " & _
                "(((TelephoneAAA.SOYADI) Like ('*')+[Sozcuk]+('*'))) OR " & _
                "(((TelephoneAAA.ADRES) Like ('*')+[Sozcuk]+('*'))) " & _
                " ORDER BY TelephoneAAA.SOYADI, TelephoneAAA.ADI;"
My thanks go to all contributers.
 

Users who are viewing this thread

Back
Top Bottom