• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 375
  • Last Modified:

DBCombo box to fill a DBGrid

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
rummy
Asked:
rummy
  • 2
1 Solution
 
DalinCommented:
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
 
DalinCommented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now