I'm working on a performance issue in a vba legacy application which - for any reason I dont know - sets the recordsource of a continuous Form via
myForm.RecordSource = newRecordsource
after the form is already open. The filter is applied after clicking a button:
DoCmd.ApplyFilter , "my filter sql"
I thought on setting a default-filter before the RecordSource is set, so the form is displayed faster. But I got Error-message 2491:
The action or method is invalid because the form or report isn't bound to a table or query.@You tried to use the ApplyFilter or SearchForRecord action or method. However, the form or report you applied the filter to is not based on a table or query, so the form or report doesn't have any records to apply a filter to.@Use the SelectObject action or method to select the desired form or report before you run the ApplyFilter action. To base a form or report on a table or query, open the form or report in Design view, and enter the table or query name in the RecordSource property.
So I have to set the filter !after! the RecordSource is set. But at the moment I set the RecordSource, my app is sending the query. So In my case the line ("myForm.RecordSource = newRecordsource") will need about 13 seconds to execute. And setting the filter afterwards results in even more time to wait.
Is there a way to prevent the form from loading all datasets until I applied the filter? As the whole app (and several others) is working as described, I can't just change the query in the RecordSource or set it in design mode.