|
-
Nov 10th, 2000, 04:45 PM
#1
Thread Starter
Junior Member
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?
-
Nov 10th, 2000, 07:34 PM
#2
Addicted Member
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!
-
Nov 13th, 2000, 09:23 AM
#3
Thread Starter
Junior Member
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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|