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.OL EDB.4.0;" & _
"Data Source=C:\Documents and Settings\n574824\Databases \SRP\SRPtw o.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
'///////////////////////// ////
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
What is the right syntax?
Any help would greatly be appreciated!!
''''''''''''''''''''''''''
' ////Load Data
Set Recordset = New ADODB.Recordset
db.Open "Provider=Microsoft.Jet.OL
"Data Source=C:\Documents and Settings\n574824\Databases
Recordset.Open "Select * from [Data] where [data]![CompanyId] = TradeLimit.ComboBox1.Value
i = 25
With Recordset
''''''''''''''''''''''''''
'Add Recordset
Cells(25, 4).CopyFromRecordset Recordset
'/////////////////////////
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.