SubForm requery from seperate form

bees292

Registered User.
Local time
Today, 17:16
Joined
Jul 26, 2005
Messages
30
Hi. Having a bit of a problem getting a subform to requery/refresh after running a query from a seperate form. The seperate form is acting as a 'search form' and running query qSearch.

I've tried various things (requery the form, subform etc) but here is the code I'm currently using:

Private Sub RunqSearch_Click()
DoCmd.OpenForm "Papers"
Forms.Papers.RecordSource = "qSearch"
Forms.Papers!Authors.Form.RecordSource = "qSearch"
Forms.Papers!Authors.Form!AuthorName.ControlSource = "qSearch.AuthorName"
Forms.Papers!Authors.Form.Requery
Forms.Papers.Requery
DoCmd.Close acForm, Me.Name
End Sub

The main form is requerying fine, but the subform isn't. Any help would be appreciated. Thanks
 
In the criteria of the underlying Query of your subFrom, Do you have your main Forms relation to the subForm.
 
Do you mean in the query 'qSearch'?
 
Three Crow,

Do you want information about the original Query the subform is based on or the Search query that I want it to requery/refresh/change record source to?

At the moment the main form is based on qPapers. The subform is based on qAuthors. Authors and Papers are linked in a many to many. So in qAuthors I have 3 fields:

AuthorID: From Join Table (linked to P.Key in Authors Table)
PaperID: From Join Table (linked to P.Key in Papers Table)
AuthorName: From Authors Table

Like I say, this works fine. But when I run the search query (qSearch) - with these fields:

AuthorName: From Table Authors
criteria = Like [Forms].[Search]![Author] & "*"
Title: From Table Papers
criteria = Like [Forms].[Search]![Title] & "*"

Thinks dont work. Hopefully that's a little more informative. Thanks for any help.
 
I figured out that this was due to me not including fields from the Join table in the search query. And in fact the requery of the subform was unnecessary.
 

Users who are viewing this thread

Back
Top Bottom