I'm pretty new to using VB6 for accessing databases and the book I have seems to skim over most of the database stuff with very little detail. Basically I have a database filled with a product list of codes, descriptions and a few other details about each product. I'd like to be able to enter the product code and retrieve all the other details about the product. I'm not really sure about the best way to do this since my book is crap, but it has most detail about SQL so I thought I'd try using it. I've added an "ADO Data Control" control to the form and pointed it to the database file using the connection string. I can get it to fill a table with the data from the database using the following code: Code: Private Sub cmdAddProd_Click() Dim SQL As String SQL = "SELECT * FROM ProdData " Adodc1.CommandType = adCmdText Adodc1.RecordSource = SQL Adodc1.Refresh Set DataGrid1.DataSource = Adodc1 End Sub ...which works, but isn't what I'm after. So now I'd like to be able to search for only a specific line based on the product code ("ProdCode"). This is where I'm getting stuck since the book doesn't seem to cover this very well and just briefly describes "WHERE, GROUP BY, HAVING, ORDER BY" which can be used to narrow the search. I tried changing one line in the code to: Code: SQL = " SELECT * FROM ProdData WHERE (ProdPacksCase = 4)" ...which sucessfully retrieves the correct records, but as soon as I try it with the product code (an example code is (ProdCode = R6600A2KJS)) I get the error "No value given for one or more required parameters". The next step would be to take a value from a text box and use that string to narrow down the search. The grid thing is only temporary. I'd like each of the details from the database to be stored in a string, but I'm not sure on how to do that either Any help would be appreciated as I'm stuck. Alternatively if you know of any web pages/tutorials that might be of help it would be most appreciated.
Sorted it, Code: ...WHERE ProdCode = '" & txtCode.Text & "' " is the correct syntax if txtCode is a text box.