Solved

DBCombo box to fill a DBGrid

Posted on 1998-03-23
2
353 Views
Last Modified: 2008-02-26
I’m using two Data Controls, one DBCombo box and a DBGrid on a VB5 form. I want to select an item from DBCombo1 and use that item in an SQL statement to populate Data2 which in turn populates the DBGrid. I’m using the Customers and Orders table from the Nwind.mdb database that comes with VB.

To populate the DBComb1 I’m using the following SQL statement as the Data1 Recorsource

SELECT CustomerId from Customers ORDER BY CustomerId

Then to populate Data2 I’m using this SQL statement

SELECT * from Orders WHERE CustomerID = "DBCombo1.Boundtext"

The DBGrid Datasource is set to Data2

When I run this program the column heads appear as the should but I don’t get any data in the column.
I think the problem in in the SELECT * from Orders WHERE CustomerID = "DBCombo1.Boundtext" statement - specifically in the Boundtext area.

Can anyone help me figure out how to get the columns to fill ?

NOTE: Please e_mail answer to jbennet@home.com

Thanks

0
Comment
Question by:rummy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 9

Accepted Solution

by:
Dalin earned 50 total points
ID: 1459635
I assume you wanted to make your second query to run when a user selected a item from the combobox.
So your 2nd SQL should be:

SELECT * from Orders WHERE CustomerID = DBCombo1.text
 no quote for the combo.text, not bounded text.

If you have more problems, let me know.
Regards.
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1459636
Rummy,
If you encounter an error of too few parameter, put your SQL statements:
SQL = "SELECT * FROM Orders WHERE [CustomerID] = '" & DBCombo1.Text & "'")

Regards

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

763 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