Link to home
Start Free TrialLog in
Avatar of ca1358
ca1358

asked on

Help with Syntax

This Excel VBA

I have this piece of code that works with this statement in it
Recordset.Open "Select * from [Data]", db, adOpenStatic, adLockOptimistic
but if I had the where statement, it doesn't

 Recordset.Open "Select * from [Data] where [data]![CompanyId] = TradeLimit.ComboBox1.Value", db, adOpenStatic, adLockOptimistic

What is the right syntax?


Any help would greatly be appreciated!!
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

' ////Load Data
 Set Recordset = New ADODB.Recordset
    db.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
           "Data Source=C:\Documents and Settings\n574824\Databases\SRP\SRPtwo.mdb;"
   
 Recordset.Open "Select * from [Data] where [data]![CompanyId] = TradeLimit.ComboBox1.Value", db, adOpenStatic, adLockOptimistic

    i = 25
  With Recordset
''''''''''''''''''''''''''''''''''''''''''
'Add Recordset

    Cells(25, 4).CopyFromRecordset Recordset
'/////////////////////////////
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial