Results 1 to 2 of 2
  1. #1
    Steven1968 is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2013
    Location
    Syracuse, New York
    Posts
    6

    Refined Query

    I have the following query but I can't seem to figure one thing out. I have a table (Employees) with items in it such as Name, Shift, Line, Etc as well as a calendar of sorts indicating if the employee is working or not.

    One table row looks like this

    32 John Baker 5 A SS O O (Null) (Null) (Null) (Null)
    ID FirstName LastName Line Shift Discipline APR1_2300 APR1_0300 Apr2_2300 APR2_0300 APR3_2300 APR3_0300
    The dates continue on to the end of the year
    The dates indicate the month day of the month and time for instance APR1_2300 is April 1st 11pm

    How can I modify the query so that it will ask me for a specific day? I want the query to tell me which names have a Null value because that indicates they are working that day and thus will generate on the report. From the above example I want to see all of the Null and WSW" values from 2 columns APR1_2300 and APR1_0300. The query below does that for me I understand however I don't want to write 365 queries one for each day of the year that is why I want it to ask me for the date(s) I am looking for.

    SELECT Employees.ID, Employees.FIRSTNAME, Employees.LASTNAME, Employees.SHIFT, Employees.LINE, Employees.MONTH, Employees.DISIPLINE, Employees.APR1_2300, Employees.APR1_0300
    FROM Employees
    WHERE (((Employees.APR1_2300) Is Null Or (Employees.APR1_2300)="wsw")) OR (((Employees.APR1_0300) Is Null Or (Employees.APR1_0300)="wsw"))


    ORDER BY Employees.DISIPLINE;

    Thanks for any and all help.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Don't understand table structure. It doesn't appear to be normalized. You have fields for each month/day/time? Why only April? Are there more fields in this table? How many?

    You want the field(s) to apply criteria for to be dynamic. The filter criteria can be dynamic parameter but don't think the fieldname can be.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

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