Results 1 to 8 of 8
  1. #1
    xmattxman is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2017
    Posts
    19

    cross tab query question

    I am trying to create a cross tab query that shows row of employee names and columns of dates and in the columns it will show the amount of hours worked that day. I have it working properly but my main issue is I need the user to enter a date range for the query. Not sure how to put that into the cross tab query. When I add in a criteria I get an error message saying it is not in the list. I added an attachment of the original query and the cross tab query I created off of that.
    Attached Thumbnails Attached Thumbnails Query.jpg  

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    put the criteria in the base query, Q1 (qryEmpAttendance)
    then make a crosstab from Q1

    NOTE: crosstabs require you to enter PARAMETERS.
    so in the crosstab query, click the parameter button
    then enter the data range fields
    forms!myForm!txtStart , date/time
    forms!myForm!txtEnd , date/time

  3. #3
    xmattxman is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jul 2017
    Posts
    19
    When I put the criteria Between [Forms]![frmEmployeeATLX]![dfsBegDate] And [Forms]![frmEmployeeATLX]![dfsEndDate]in the first query then make the cross tab I get the error Microsoft access database engine does not recognize [Forms]![frmEmployeeATLX]![dfsBegDate] as a valid field name or expression?

    I just saw the last half of your post I will try that out.

  4. #4
    xmattxman is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jul 2017
    Posts
    19
    That worked perfectly! Thanks for the help! I had one other question. Right now the columns are showing the amount of hours they worked that day. Is there a way I can make it so if there is a number in that field it shows present and if it is blank it show an X? The field is ATX_TIME_AMOUNT

  5. #5
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    The Xtab sums values. X is not a number.

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,975
    Use an IIF statement in another query based on your crosstab query

    Code:
    IIf([atx_time_amount]>0,"present","X")
    Ranman has pointed out that you can't add text to a number field ...in the sum field of your crosstab
    Last edited by orange; 01-17-2018 at 06:10 PM. Reason: adjusted code tags (orange)
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  7. #7
    xmattxman is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jul 2017
    Posts
    19
    That worked great but I need the X to be put where a field is blank? We don't have any negatives on the report only >0 and blanks for when they are absent.

  8. #8
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,975
    Do 2 steps:
    1. Create your crosstab query
    2. Create a new query based on that using the IIf statement I posted before as an additional field

    Use the 2nd query for your report
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

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

Similar Threads

  1. Replies: 4
    Last Post: 08-15-2017, 08:44 AM
  2. Cross Tab Query
    By balajigade in forum Access
    Replies: 1
    Last Post: 09-09-2015, 01:12 PM
  3. Case Management Cross-Refence question
    By Fuzzyluzzi in forum Database Design
    Replies: 11
    Last Post: 09-01-2015, 09:44 AM
  4. Cross Tab Query
    By vishal09 in forum Access
    Replies: 3
    Last Post: 04-04-2015, 10:52 AM
  5. Replies: 4
    Last Post: 08-13-2012, 04:39 PM

Tags for this Thread

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