Results 1 to 6 of 6
  1. #1
    Savaot is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    May 2013
    Posts
    4

    Smile Compare two records in Access 2010

    Hello all,

    Here is the problem that I have and for which I need help.
    In db I have a table that have one record per customer per year that has answers from the yearly survey on 15 questions. Answers are numerical values between 0 and 5, and here is potential scenario.

    Customer Date Q1 Q2 Q3 ... Q15
    JohnDoe 2011 1 2 1 5
    JohnDoe 2012 2 1 3 5
    JaneD 2011 2 2 2 0
    JaneD 2012 2 1 1 1
    ....

    Using Query wizard like this one

    SELECT Questionnaires.Client, Questionnaires.[Q of L Date], Questionnaires.Q1, Questionnaires.Q2, Questionnaires.Q3, Questionnaires.Q4, Questionnaires.Q5, Questionnaires.Q6, Questionnaires.Q7, Questionnaires.Q8, Questionnaires.Q9, Questionnaires.Q10, Questionnaires.Q11, Questionnaires.Q12, Questionnaires.Q13, Questionnaires.Q14, Questionnaires.Q15FROM Questionnaires
    WHERE (((Questionnaires.Client) In (SELECT [Client] FROM [Questionnaires] As Tmp GROUP BY [Client] HAVING Count(*)>1 )))
    ORDER BY Questionnaires.Client;

    I was able to produce grouping and have tmp table where the records are grouped by client and sorted by date in ascending order.

    I want to use that query as a foundation for the report that will look something like this

    Client's Questionnaires
    Customer Date Q1 Q2 Q3 ... Q15
    JohnDoe 2011 1 2 1 5
    JohnDoe 2012 2 1 3 5
    Analysis Up Down Up ... Same



    JaneD 2011 2 2 2 0
    JaneD 2012 2 1 1 1
    Analysis Same Down Down ... Up

    Where I can replace words 'same', 'up' or 'down' with arrows and/or colours

    In report wizard I can only choose between SUM, AVG and so on but nothing that I need. I guess there is need for some macro or VBA and that is where I'm stuck.
    Your help is appreciated.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I don't understand what you want. What does 'Analysis Up Down Up ... Same' mean? What behavior are you trying to implement?

    Reports are not really intended to be interactive.
    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.

  3. #3
    Savaot is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    May 2013
    Posts
    4
    I don't want reports to be interactive indeed. Analysis is the label for the client's summary; it can be 'Results of the comparison' or anything else. Words 'Up', 'Down' or 'Same' are the results of the comparison of the values in the Q1 columns and other columns respectively i.e. for JohnDoe for 2011 in Q1 I have '1' and for the year 2012 in Qq I have '2'. So in the 'Results of the comparison' for column Q1 value went up from 1 to 2 and I'll like to see word 'Up' or painted in green in the Q1 summary and so on.
    Hopefully it is more clear with this explanation.
    Thanks

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    So you want to compare the data in pairs of records from the same table?

    Never seen this one before. Don't think will be easy. Comparing data from records of same table usually isn't.

    One approach:

    Build a query that has all the data fields and also creates a field with calculation:
    PriorYear: [Date]-1

    Now build a query that joins the source table with the first query by linking on the [Date] and PriorYear fields. This will get the 2 years of data side-by-side.

    Now expression in textbox like:

    =IIf(Query1.Q1=Tablename.Q1, "Same", IIf(Query1.Q1<Tablename.Q1, "Down", "Up"))
    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.

  5. #5
    Savaot is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    May 2013
    Posts
    4
    Thanks so much. It is really intriguing approach and I'll give it a try and post my results/hurdles.

  6. #6
    Savaot is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    May 2013
    Posts
    4
    Thanks June7,

    It worked nicely. Using your approach there was no need for macros or VBA, just a bit of tweaking the report and it solved my problem. If anyone wants specific details and June7's idea need an example do not to hesitate to send me a request. Thanks again JUNE7.

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

Similar Threads

  1. VBA Across Multiple Records (Access 2010)
    By Scorpio11 in forum Access
    Replies: 3
    Last Post: 03-28-2012, 11:33 AM
  2. Compare Two types of records from one table
    By pstrahan in forum Access
    Replies: 1
    Last Post: 08-10-2011, 11:22 AM
  3. Replies: 6
    Last Post: 07-23-2011, 12:35 PM
  4. Access compare and sum records in two tables
    By piszczel in forum Queries
    Replies: 8
    Last Post: 05-23-2011, 02:07 AM
  5. Compare records in 2 tables
    By RalphJ in forum Access
    Replies: 13
    Last Post: 03-06-2011, 07:43 AM

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