Re: display query result on subform
- From: tracktraining <tracktraining@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 29 Jul 2008 16:53:00 -0700
Thanks so much. Your database was very helpful.
"Allen Browne" wrote:
Your code creates an instance of the QueryDef, assigns the parameter, and.
then doesn't do anything with it. Setting the RecordSource to the name of
the query doesn't use the QueryDef you created (which goes out of scope at
the end of the procedure.
It might be possible to name the parameter in the query to something like:
Then just bind the subform to the query, and it will read the value from the
If you always want to filter the form by the SearchDocID value, you could
simplify the whole process by omitting that parameter from the query.
Instead set the LinkMasterFields and LinkChildFields properties of the
subform control on your main form. No code is needed.
If there are actually lots of parameters you want to offer, this approach
Search form - Handle many optional criteria
It builds the WHERE clause of the SQL statement dynamically, and then
filters the form.
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"tracktraining" <tracktraining@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
I have several queries that I already wrote. I am in the progress of
creating a user interface form. I want to call the queries and display the
results on a subform. I have written a short code (see below), but i keep
getting an error (Error Message: Run_time error '2467'. The expression you
entered refers to an object that is closed or doesn't exist). Is the code
below correct? Any suggestions/advices on how to make this work?
Private Sub Read_Click()
Dim qd As QueryDef
Set qd = CurrentDb.QueryDefs("SearchQuery")
qd.Parameters("Document ID") = Me.SearchDocID
Me.SearchResults.Form.RecordSource = "SearchQuery"
THANKS SO MUCH.
- Prev by Date: Re: Paragraph Format from Word in Memo Field
- Next by Date: Re: HELP! does access has limit in back out data?
- Previous by thread: Re: display query result on subform
- Next by thread: Re: Close one mdb open another