Results 1 to 8 of 8
  1. #1
    tragatz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    5

    Return Field Name from a table when dates match.


    First time question here. please be patient with me. I have a report that has a rolling calendar as column headers. first day of month to end of month left to right. each row represents a unique "Ship". My table rows are also "Ships" (i.e. Ship1, Ship2) which have dates when events occur. The Field Name in the Table represents the event. (i.e. Started, Inspected, Sold). My goal is to create a formula within the report row that returns the Field Name when dates match. For Example, in my report, Ship 1 shows a Sold date of 10/2/14. I would like for my report row for Ship 1 to return the Field Name "Sold" in the column 10/2/14. I hope I have explained this well enough, and followed the rules for the forum. Thank you in advance. Tom

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    This sounds like a CROSSTAB query is what you need. Tho I am unclear on your layout...make a query to get the data you need,
    then use THAT query to build a crosstab query USING THE WIZARD.
    (instead of SUM or AVg for the VALUE part of the wizard, you will want FIRST)

  3. #3
    tragatz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    5
    Thank you. I wondered if I was approaching it incorrectly. I will look at the CROSSTAB now.

  4. #4
    tragatz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    5

    Attempt to further explain with picture attempt.

    Click image for larger version. 

Name:	report.jpg 
Views:	5 
Size:	42.1 KB 
ID:	18296 report with dates. each row is a "Ship". The "OTD_PLAN" is an example of what I would like to see.Click image for larger version. 

Name:	table.jpg 
Views:	5 
Size:	31.5 KB 
ID:	18297 Table. as shown, the header is what I would like to see returned. OTD_PLAN has a 10/2/14 date, so I would want it to show OTD_PLAN on 10/2/14 in the report. I have cut off the ship names for privacy, but it is easy to imagine ship1, ship2, and so on for each row. When an event happens, it is entered in the table as a date in the column that coincides with the event. (OTD_PLAN is an event). I am not sure how to make a crosstab work for this. I would be happy with "It is impossible", then I would quit trying. not sure I would believe it though! Thanks.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Your data structure is not normalized. Normalized structure could easily be pivoted with CROSSTAB. However, building a stable report to run perpetually based on CROSSTAB is not easy because of the dynamic nature of CROSSTAB, especially when pivoting on date values. If there are no records for a date then the CROSSTAB would not generate a column for that date and the column names continually change.

    There's almost always a way - question is, is it worth the effort? 'Pivoting' this data would probably require VBA code and a 'temp' table.
    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.

  6. #6
    tragatz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    5
    I had hoped for something like a vlookup, or dlookup formula in the report that would match the ships, and dates, and return the header name. I have had no luck with our experts here, so I knew it was a long shot. thanks.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Aside from a CROSSTAB, field names in Access query object cannot be dynamic.
    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.

  8. #8
    tragatz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    5
    Thank you. that is probably the answer I am looking for. I will seek a different route. thank you for taking the time to reply.

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

Similar Threads

  1. Replies: 5
    Last Post: 04-23-2013, 01:42 PM
  2. Replies: 3
    Last Post: 07-16-2012, 08:32 PM
  3. Replies: 16
    Last Post: 03-13-2012, 03:47 PM
  4. Replies: 5
    Last Post: 03-01-2012, 12:59 AM
  5. Dlookup to match two criteria and return value
    By randolphoralph in forum Programming
    Replies: 20
    Last Post: 05-20-2010, 12:27 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