By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,482 Members | 2,438 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,482 IT Pros & Developers. It's quick & easy.

Filter table from VB Code

ChaseCox
100+
P: 294
Is there a way to filter tables in a Database with only VB Code, or do you have to use the queries? If this is possible I would like to eliminate my queries and filter the tables in my database with just code. I would also like the results to be output to a new table in the database and maybe to an excel file. I have no idea how this would work, so I will need alot of help if this is possible. I would like to use my form to still pass the values in.
Feb 8 '07 #1
Share this Question
Share on Google+
2 Replies


nico5038
Expert 2.5K+
P: 3,072
Basically You need a query with criteria to filter a table.
Changing such a query into a MakeTable query will create a filtered copy.

Filtering from code is done on a form, e.g. a master form with a datasheet subform.
There the right-click (also usable on a table) can be used to filter with an AND relation, or the FilterByForm button when an OR relation is needed.
In code you can also apply a filter with:

Me.subformname.form.filter = "ID=" & me.ID
Me.subformname.form.filteron = True

Such a filter (and a right-click filter) can be added as a WHERE clause to a query created in code.

Nic;o)
Feb 8 '07 #2

NeoPa
Expert Mod 15k+
P: 31,186
Is there a way to filter tables in a Database with only VB Code, or do you have to use the queries? If this is possible I would like to eliminate my queries and filter the tables in my database with just code. I would also like the results to be output to a new table in the database and maybe to an excel file. I have no idea how this would work, so I will need alot of help if this is possible. I would like to use my form to still pass the values in.
Although you could implement a sort of filtering in VB code it would not serve your purpose well. The result would only be available to your code for a start, which would need to be developed further to output the results somewhere accessible. It really has many drawbacks, not least of which is the inefficient execution.
I'm curious as to why you would want to bypass one of the (possibly the most) fundamental tools of database manipulation and processing?
Feb 10 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.