Syntax error in query expression

jagu147

Board Regular
Joined
Mar 19, 2014
Messages
71
hi need help solve error in my qury


Code:
 Public Sub populate_picks1()
On Error GoTo ErrorHandler
    Dim conwatt As ADODB.Connection
    Dim Recsetwatt As ADODB.Recordset
    Dim strSQL As String
    
    Set conwatt = New ADODB.Connection
    Set Recsetwatt = New ADODB.Recordset
    strSQL = ""
    
       Call set_path
    conwatt.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & _
       "Data Source=" & strDatabase_Path & " Database.accdb" & ";"
     StrUserWinID = "Tbl_Production"
     area = "Report mont"
      strSQL = "SELECT distinct(ALS_No) FROM " & StrUserWinID & " where Activity_Name= " & area & " "   
 Recsetwatt.Open strSQL, conwatt, adOpenDynamic, adLockOptimistic

in table actvity_name value is "Report mont" but it showing the syntax error(missing oprator)



please help

regards,
jagu147
 
Last edited by a moderator:

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
If the field Activity_name is text you need to enclose the criteria in single quotes.

Also there should be no brackets around ALS_No.
 
Upvote 0

Forum statistics

Threads
1,223,261
Messages
6,171,080
Members
452,377
Latest member
bradfordsam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top