Using user input in a query to select different table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • onyris
    New Member
    • Aug 2008
    • 42

    Using user input in a query to select different table

    Hi

    have this query which works ok now :

    Code:
     SELECT *
    FROM [Table]
    WHERE (((Table.published) Like '*'&[Forms]![Search_Records]![Combo7]& '*' And (Table.published) Like '*'&[Forms]![Search_Records]![Combo9]& '*' and  (Table.address) Like '*'&[Forms]![Search_Records]![txtcity]& '*'  ));
    and instead of using the default table which in this case is [Table] , i want to let the user to input which table the query to search on , and what i did is this

    Code:
    SELECT *
    FROM [Forms]![Search_Records]![txttable]
    WHERE ((([Forms]![Search_Records]![txttable].published) Like '*'&[Forms]![Search_Records]![Combo7]& '*'
    And ([Forms]![Search_Records]![txttable].published) Like '*'&[Forms]![Search_Records]![Combo9]& '*' 
    and  ([Forms]![Search_Records]![txttable].address) Like '*'&[Forms]![Search_Records]![txtcity]& '*'  ));
    but for some reason is not working.
    Can anyone tell me what am i doing wrong ??

    Thanks.
Working...