Executing Access queries with Data Control and parameter passing 
Author Message
 Executing Access queries with Data Control and parameter passing

I am trying to execute an Access query from a VB program. The Access query needs a parameter setting in its condition clause. I do
this with the following program. But still I cannot link the results to a Data Control. The following should work but doesn't:

    Dim MyDB As Database, MyQuery As QueryDef
    Set MyDB = OpenDatabase("h:\vb3\biblio2.MDB")
    Set MyQuery = MyDB.OpenQueryDef("By state")  
    MyQuery![Enter State] = "NY"     ' Set parameter.
    Data1.RecordSource = MyQuery.SQL
    Data1.Refresh

I get an error on the last command saying "1 parameter expected but 0 returned" or something similar. While I know that the query
gives more than one row result (with a print loop). Strange! Anybody out there who has an idea how to link the query result to a data
control?

Thanks,
Pjotr van Schothorst



Sat, 30 Aug 1997 07:34:36 GMT  
 Executing Access queries with Data Control and parameter passing
There is nothing returned from your example!

Try creating a dynaset with the query you have and see what
results you get from that 1st...



Mon, 01 Sep 1997 21:03:16 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Passing Parameters to stored parameter queries using VB 5's Data Controls

2. Executing Access queries with parameter passing

3. Data Controls and Access 2.0 Queries with parameters

4. How do I pass data to parameter query

5. Passing Data to Parameter Queries

6. Passing Parameters to SQL Query in a contols data source

7. Executing Parameter Query with 2 parameters

8. passing data controls and control arrays as parameters

9. Pass Access Query Parameters from Excel

10. Passing multiple parameters to Access query using Form List Box

11. Stored, Pass Through, Parameter Query on Access 2k and SQL Server 7

12. Passing parameters from Visual Basic forms to Access queries

 

 
Powered by phpBB® Forum Software