Solved

DBCombo box to fill a DBGrid

Posted on 1998-03-23
2
351 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
  • 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…

785 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