pass a parameter to a query programmatically 
Author Message
 pass a parameter to a query programmatically

Is there any way to pass a parameter to a query
programmatically? I've got a query which has the
following condition in one of it's columns:

<=[Enter First Date]

I'd like to pass that value without the query prompting
me for it, preferrably thru a macro or VBA function.

ultimately, I'll call either the macro or function from
Excell.

Any ideas?

Thanks



Sun, 16 Jan 2005 00:45:03 GMT  
 pass a parameter to a query programmatically


Quote:

> <=[Enter First Date]

> I'd like to pass that value without the query prompting
> me for it, preferrably thru a macro or vba function.

Check out the Parameters collection of the Querydef object: it goes
something like this:

 dim qdf as Querydef
 dim rs as Recordset

 set qdf = CurrentDB().OpenQuerydef("MyQueryName")
 qdf.Parameters("[Enter First Date]") = DateSerial(2002,2,11)
 set rs = qdf.OpenRecordset

 do while not rs.eof
    debug.print rs!MyFirstField, rs!MyOtherfield
    rs.movenext
 loop

 rs.close
 qdf.close

HTH

Tim F



Sun, 16 Jan 2005 02:57:28 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. passing parameter to a parameter query

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

3. Passing Parameters into a Pass-Through Query

4. Passing parameters to SQLServer using a Pass-Through query

5. calling parameter query from a parameter query

6. Pass Access Query Parameters from Excel

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

8. Passing Query Parameter In VBA

9. How do I pass data to parameter query

10. Passing two parameters tp a query in VBA

11. Passing parameter to reports query

12. Passing parameters from VBA to a Query

 

 
Powered by phpBB® Forum Software