Subform based on query not updating with new information ??

pfiroz

Registered User.
Local time
Today, 09:16
Joined
Jan 21, 2009
Messages
27
Hey :)
I need some help figuring out why my subform will not update with new data. The subform is based on a query. The query is based on the search criteria a user selects on the main form. So a user selects a name to search on then click the 'Find' button. This runs code that sends a new query def to the query and then the subform should display what results from the updated query. The subform does display whats in the query if I close out the whole form and then reopen it. But if I change the search criteria and click the button, the subform only keeps the same information it had before. However, the query itself IS changeing correctly to reflect the new search criteria. ??
Here is part of the code :
Code:
    Dim qryDef As QueryDef
    Dim qrycriteria As String
    qrycriteria = "select * from DocsWithShortLink where " & strDocList
    Set qryDef = CurrentDb.QueryDefs("qrytesting")
    qryDef.SQL = qrycriteria
  
  'Me.sfSearchResults.Form.Filter = strDocList & "not(" & Notlist & ")"
  'Me.sfSearchResults.Form.Filter = strDocList
  'Me.sfSearchResults.Form.FilterOn = True
  Me.sfSearchResults.Form.Requery
  Me.sfSearchResults.Requery
  Me.sfSearchResults.Form.Refresh
  Me.sfSearchResults.Visible = True
  Me.Refresh

Appreciate any help!!!
 
Only thing i can think of is to make sure your subform container name is sfSearchResults
 
I checked that. It is sfSearchResults.
?? not sure why I have to close the main search form and then when I reopen and click the find button it will have the data from the previous search criteria in the subform (the data from the previous query output). But the query itself (which the subform is based on) is changing/updating correctly.??
Now I do update the query and in the code after the main search form and subforms are open. So maybe the subfrom just pulls in the data in the query when it first opens but then after the button is clicked and the code runs, the query gets updated but the subform still has the old query data ?? but I thought that the .requery and .refresh should take care of that??
How can I get the subfrom to pull in new data from the query AFTER its already been opened ??
 

Users who are viewing this thread

Back
Top Bottom