Requery doesn't update datasheet subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form with a tab control where the first tab is a group of unbound controls used to enter data to search a table for data - a query is generated and saved using an SQL statement via code. If a single result is obtained, a new form is opened to display all the record details, but if multiple results are obtained, I switch views to the second tab on the form which has a datasheet view subform to display the query results. My problem occurs when the user switches back to the first tab and conducts a different search, the query is updated (I manually open it to check), and the code switches to the second tab, but the new query results are not displayed - the original query results are still there. I have tried several variations of the requery command to try and get this working, all of which have failed. The only thing I have been able to do to work around the problem is to close and reopen the form. Right now, my form name is FrmSelection, subform name is SubFrmResults, and the control for the subform is SubFrmReslutsCtl. Here are some of the variations of requery I have tried to get the datasheet view of the subform to dsplay the updated query without closing and reopening the main form:

Me.SubFrmResultsCtl.Requery

SubFrmResultsCtl.Requery

SubFrmResults.Requery

Me.Requery

Dim ctrl As Control
Set ctrl = Forms!FrmSelection!SubFrmResultsCtl
ctrl.Requery

None of these worked - any ideas? Are there other code steps I need to do? Does the subform need to have the focus for the requery method (I think I tried it, but probably not with all the above iterations), or some other setup I am not doing? Other factors possibly of interest - the background table is not meant to be updated from this application (it is for viewing purposes of the background table only), so I have the subform properties set for No Edits, Additions or Deletions (but since the source for the subform is actually a query of the table - a query that needs to be changed, could this be a problem?). The subform is set for Dynaset Recordset type, and since this is for viewing only, No RecordLocks.

Thanks in advance for the help,

Verle
 
Dim ctrl As Control
Set ctrl = Forms!FrmSelection!SubFrmResultsCtl
ctrl.Requery

None of these worked - any ideas?

Try
Forms!FrmSelection!SubFrmResultsCtl.Form.Requery


-- Dev
 
Back
Top