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
Solved

DBCombo box to fill a DBGrid

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA open file from excel cell 4 44
Access Object Property from VBA Module in Excel 2010 2 37
How to make an ADE file by code? 11 94
Advice in Xamarin 21 96
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…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…

856 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