Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 627
  • Last Modified:

Filters - easy question (need quick answer)

I am just missing something here I think, but I am trying to
run a filter on a table.  Heres the background, the user selects customers from a multi-pick list, these are then read into a table.  That part works.  

I then have a query that joins on the customer name to a table with customer data, and returns all the customer data, in effect only showing data about selected customers.  This is what my code does...

'DoCmd.OpenQuery "filtertest", acViewNormal, acEdit
DoCmd.OpenTable "RespondentList", acViewNormal, acEdit
DoCmd.SelectObject acTable, "RespondentList", False
DoCmd.ApplyFilter "filtertest"

on this last line (filtertest is the query mentioned above) I get an error Runtime error 2488, says that I have not selected a table to perform the query on.  And mentions that I should use SelectObject, which I do, but no to avail.  I need this answered pretty fast...

thanks, Matt Fischer
0
mfischer2
Asked:
mfischer2
1 Solution
 
LesandCommented:
Perhaps I don't know what you are trying to accomplish.

If you want to return a datasheet by means of a query that has been limited to a list of user-selected customers then do the following:

Create a query with 2 tables:
    All_Customers_DataTable
    User_Selected_Customers_List

In the QBE grid, link the tables on a common key field and  make sure that the link returns only records where the two fields are equal.  Save the query.
Now it will automatically return records filtered to those listed in the User_Selected_Customers_List

In code you can use docmd DoCmd.OpenQuery "filtertest", acViewNormal, acEdit   and it should always return the recordset limited by the user selections


0
 
mfischer2Author Commented:
I ended up not using filters, but thanks for the help.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now