Results 1 to 3 of 3
  1. #1
    Vicker is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    2

    Query criteria, multiple tables

    Hi

    The problem i have is pretty simple actually.



    I have DB, with 2 tables in it. Main tables are Profession and Salary (which inlcude various information on Profession and Salary respectively).
    Now i have built a form that includes 2 comboboxes.

    In the first one, the user chooses his own name from the list and in the other box he chooses the table he wishes to examine.

    So if Mr. Smith would like to receive he's info on in the Salary table, he would choose "Mr. Smith" from the first combobox and "Salary" in the second combobox. After hitting a command button the query would show all the records Mr Smiths records from the "Salary" table.

    The problem is that i really have no idea how to do this.

    Ideally the SQL would look something like this:

    SELECT *
    FROM Forms!my_form!choose_table
    WHERE Forms!my_form!choose_table.Name = Forms!my_form!choose_name

    But i know that you cannot actually do that.

    Should i try to number the table names by using slave tables which identifies which table i want to be examening?

    Any help would greatly be appreciated.

  2. #2
    jwreding is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2011
    Posts
    34
    I don't know exactly how to do it with SQL, but in my DB I have several queries that use the value of a combobox as criteria. In the query builder, I just use the expression builder to use the combobox value as the criteria.

    For example, I have the CustomerID field criteria set to the value of a cboShipperName combobox. I went to SQL view and the part of the WHERE clause that had this criteria looked like this (I couldn't paste all the code because it's a long, complex query):

    ((Loads.CustomerID)=[Forms]![mnuDailyOps]![cboShipperName])

  3. #3
    Vicker is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    2
    Now that i have thought about this more, i think that this is impossible to accomplish without some VBA

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Matching based on criteria from multiple tables
    By Jonpro03 in forum Database Design
    Replies: 13
    Last Post: 08-04-2011, 10:29 AM
  2. Replies: 1
    Last Post: 07-13-2011, 11:00 AM
  3. Query on criteria from two tables
    By jpkeller55 in forum Access
    Replies: 4
    Last Post: 09-07-2010, 06:43 AM
  4. Multiple criteria query
    By DJ-Specter in forum Queries
    Replies: 1
    Last Post: 09-23-2009, 04:47 AM
  5. Need help with tables and query criteria
    By DevintheDude in forum Access
    Replies: 0
    Last Post: 09-12-2007, 08:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums