Solved

Help with Syntax

Posted on 2006-07-11
1
154 Views
Last Modified: 2010-04-30
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
'/////////////////////////////
0
Comment
Question by:ca1358
1 Comment
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 17085627
   
assuming the CompanyID is numeric:

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now