PDA

Click to See Complete Forum and Search --> : My stupid ADO / Datagrid problem


MattS
Nov 10th, 2000, 03:45 PM
Hey all,

I'm trying to make my Datagrid show data based the contents of a combo box. I've got an Adodc set up, and have pointed the DataSource of the Datagrid to the main table in the database I'm using. Here's an example of the code I'm using:

Private Sub cmbProdFamily_Click()
sqlQuery = "SELECT Catalog_Number FROM IES WHERE Brand
= 'Metalux' AND Product = 'Paralux IV'"
Adodc1.RecordSource = sqlQuery
Adodc1.Recordset.MoveLast
Adodc1.Recordset.MoveFirst
Adodc1.Refresh
End Sub

I've used this method sucessfully with a standard Data control and an MSFlexGrid, but when I try to switch the recordsource for the Adodc in this case it generates this error:

"Syntax error in FROM clause"

I'm pretty comfortable with SQL, so what's up?

P.S.W.
Nov 10th, 2000, 06:34 PM
Well, it could be (maybe?) that the CommandType property of your ADODC is not set to adCmdText; thus you're getting the error when you try to change the RecordSource to SQL at runtime. I've had that happen to me before. Also, I'm assuming you're doing the .MoveLast & .MoveFirst commands to get the recordcount? This is unnecessary in ADO. The .recordcount will be available immediately after setting the RecordSource.

Hope that helps!

MattS
Nov 13th, 2000, 08:23 AM
P.S.W.:

Thanks very much for the reply. It takes some getting used to switching from DAO to ADO. After I switched the command type, everything worked great. Thanks again!