Build the 'where' sql statement following search form selection

I just wanted to add this.

I personally never filter a form. I change the record source
In your case instead of

Forms![Contact List].Filter = "ID In (" & SelectedID & ")"

I would use

Forms![Contact List].RecordSource = " SELECT * FROM [Contacts Extended] WHERE ID In (" & SelectedID & ")"

And never use space in object names.
Are filters not recommended even for a temporary search? As for the naming convention, I am aware of that, but I started this DB by using the access contacts template, and it was supposed to be a very simple small thing, but the person who requested it, kept asking for new stuff to be added, and it grew much more than I expected.
Had I known from the start, I would’ve built things differently.
Thanks again for your help and time.
 
Are filters not recommended even for a temporary search?
Filters are fine in many situations, but not in others. If this is a relatively small database you will never see an issue. However, if you have a lot of data (especially on an external database) you may want to reduce the records you pull. If you make a query to filter the results it the external database will only return the filtered set. However, if you do this by applying a filter to the local database then it would have to pull everything first then apply the filter. Imagine you have 1Million records on an external database and your filter returns only 5. Better to request only the 5 from the external db instead of pulling all 1 million and then filtering it to the 5 you need.
 

Users who are viewing this thread

Back
Top Bottom