Results 1 to 2 of 2
  1. #1
    FALAGELOLOGIST is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    14

    Question Help: I need one value to represent the two values below it in a list box

    Edit: problem solved. See below.

    I am very new to Access but have learned a lot in a month. I do not understand VBA or SQL for the most part so I may need some explanations to be dumbed down.

    I have a query with one column that has two values—either 1 or 2 or a yes/no check box. I am using both to see if I can get either one to work. A little background - 1 (or checked) would mean this person is a contractor and 2 (or unchecked) would mean a government employee.



    That one column has a criteria linked to a list box in a form using the "Build..." tool. It looks like this in the criteria box:
    [Forms]![NavigationPane]![ContractorSelection]

    That query is linked to a report so when I select either Yes/No or 1/2 in the list box and click the corresponding command button that report when opened will only show the contractors or the government workers. I want a third option in the list box though. Both. How can I make it so if I select that third option in the list box it will include both contractors and government employees?

    I tried having the table column with the corresponding values be formatted to text with the values "1", "2", and "1 or 2." I figured this would work because if I replace "[Forms]![NavigationPane]![ContractorSelection]" in the criteria field with "1 or 2" it works. But if I use the build tool to fetch it from another table, it doesnt. It works for just contractors or government workers, but not both.

    I do not want to have to create one report for both categories and another report for either/or. I'm fine with making another query but since a report can only be connected to one query (I think) I don't see how that can work.

    I'm not sure if it helps, but here is the SQL for the query:

    SELECT Trips.TripID, Travelers.Traveler, Divisions.Division, Trips.DepartureDate, Trips.ReturnDate, Trips.MonthlyNumber, Trips.Destination, Trips.Cost, Trips.[TripCancelled?], Trips.Purpose, Trips.Justification, Travelers.[GovernmentContractor?], Travelers.[GovContractor?]
    FROM Travelers INNER JOIN (Divisions INNER JOIN Trips ON Divisions.[DivisionID] = Trips.[DivisionID]) ON Travelers.[TravelerID] = Trips.[TravelerID]
    WHERE (((Trips.MonthlyNumber)=[Forms]![NavigationPane]![MonthlySelection]) AND ((Travelers.[GovContractor?])=[Forms]![NavigationPane]![ContractorSelection]))
    ORDER BY Trips.DepartureDate;

    A huge thank you to anyone taking the time to help!

  2. #2
    FALAGELOLOGIST is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    14
    Problem solved!

    In case anyone lands on this page because of a google search, here's the answer I got from another forum:

    It sounds to me like you just need to use Grouping in the report to separate them...

    You can use the same query and the same report object for all 3 options. Just put OPTIONAL criteria in the query:
    [Forms]![NavigationPane]![ContractorSelection] Or [Forms]![NavigationPane]![ContractorSelection] Is Null

    (Do this is the query builder grid, in a single criteria cell for the appropriate column. Once you've done it, saved it, and closed it, if you open it again in Design view you will see that Access has done its magic with the SQL and is representing it differently in the grid.)

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

Similar Threads

  1. Replies: 6
    Last Post: 02-04-2014, 09:24 AM
  2. Replies: 4
    Last Post: 10-24-2011, 11:14 AM
  3. Replies: 2
    Last Post: 02-28-2010, 06:52 PM
  4. Replies: 11
    Last Post: 01-26-2010, 08:41 AM
  5. Replies: 1
    Last Post: 12-29-2005, 01:15 PM

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