Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Help with Syntax

Posted on 2006-07-11
1
Medium Priority
?
201 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 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

916 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