View Full Version : Basing a recordset on a query


bleakcabal
03-19-2002, 04:10 AM
Hi, I have a problem with an access application. What I want to do is create a recordset and instead of doing what I am currently doing :


Dim rsProduits As New Recordset

stQuery = "SELECT * FROM Produits WHERE " &
WHEREClause & " ORDER BY NoSousCategorie;"

rsProduits.Open stQuery, CurrentProject.Connection, 3, 3


I want to specify an existing query in the database as the source of the recordset. I have tried several methods myself including doing

rsProduits.Open QUERYNAME, CurrentProject.Connection, 3, 3, 2

and

rsProduits.Open QUERYNAME, CurrentProject.Connection, 3, 3, 1

Or just putting the query name instead of my string and all methods give me the following error : Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

The query I use returns rows in query source and just to be sure it works I have created a sample report which uses this query as it's source property and everything works fine.

Thanks in advance for any kind of help you may give and if you need any clarifications just ask.

Rich
03-19-2002, 04:16 AM
Something like Me.Recordsource= ("MyQuery")
or just base the report on the query.

bleakcabal
03-19-2002, 05:10 AM
Unfortuntly the current use does not use a report. I am using the recordset to write to a text document HTML tags. Also when I try to set the query as the form as record source I get an error. The reason is that the query uses information from a a field on the form that is not set when the forms open. Tough I think I may have found an awnser while writing this post, I will try and either set the source property of the form when the button to generate the document or something like that. I will get back to this forum with the results.

bleakcabal
03-19-2002, 06:47 AM
Yeah it worked, im ok, thanks for the awnser.