Page 2 of 2 FirstFirst 12
Results 16 to 25 of 25
  1. #16
    cwager990 is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Posts
    16


    Quote Originally Posted by JSR View Post
    My personal preference is to do this type of thing differently. Make a query on the two tables joined by customer ID, turn on totals, Group by customer ID, Max([Date Of Purchase]) as LastPurchaseDate. Save this query.

    Now, to get all the data associated with just the last purchase for each customer, create another query based on the two tables and the first query. Join the two tables by customer ID, and join the purchase table to the query by customer ID and Date Of Purchase to the query's LastPurchaseDate. No totals, just output every field you want to see.
    This worked thank you, is there a way to do this so that the record set is updateable ?.

    Sent from my SM-N950F using Tapatalk

  2. #17
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,425
    Cross posting isn't bad per se. Doing it and not declaring it in both forums with links to each other is the problem. Here's another tip: if I see a thread is cross posted, I probably won't get involved because it can be too much trying to follow conversations and sort suggestions between forums. Plus I don't belong to any other Access forum anyway. I'm revealing my own bias here and maybe I'm alone in this thinking. The exceptions would be if a) immediately I think I know the answer, or b) I'm intrigued by the issue at hand.

    Anyway, here's a good link for the many reasons why a query is not updatable http://allenbrowne.com/ser-61.html You've got at least 2 of them covered. I think it's time we saw a good example of table data, or zip a db copy with fake names and leave out phone numbers and such. Based on some of what you've posted, normalization might be an issue here, such that it's causing you to search for complicated solutions where the data is (possibly) the problem.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #18
    cwager990 is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Posts
    16
    Quote Originally Posted by Micron View Post
    Cross posting isn't bad per se. Doing it and not declaring it in both forums with links to each other is the problem. Here's another tip: if I see a thread is cross posted, I probably won't get involved because it can be too much trying to follow conversations and sort suggestions between forums. Plus I don't belong to any other Access forum anyway. I'm revealing my own bias here and maybe I'm alone in this thinking. The exceptions would be if a) immediately I think I know the answer, or b) I'm intrigued by the issue at hand.

    Anyway, here's a good link for the many reasons why a query is not updatable http://allenbrowne.com/ser-61.html You've got at least 2 of them covered. I think it's time we saw a good example of table data, or zip a db copy with fake names and leave out phone numbers and such. Based on some of what you've posted, normalization might be an issue here, such that it's causing you to search for complicated solutions where the data is (possibly) the problem.
    I will redact the table and upload the file.

    Sent from my SM-N950F using Tapatalk

  4. #19
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,941
    maybe I'm alone in this thinking
    No, you are not. I don't expect newbies to understand - the argument 'I want as many possible answers' is perfectly valid but from a responder perspective there is 'I don't want to spend time working on providing a solution that has already been provided'. Time is given voluntarily and freely and most don't like to see time wasted. Couple this with the number of regular responders with an in depth knowledge of access/vba is relatively small - not counted but would suggest perhaps less than 100 worldwide - although I am sure there are many thousands of users with in depth knowledge but they don't use the forums (at least to help others). So it comes down to common courtesy which is what the link provided explains. The generally standard notification of 'cross posted here' with a link is to advise responders, potential or otherwise, and not an admonishment to the OP.

  5. #20
    cwager990 is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Posts
    16
    Quote Originally Posted by Ajax View Post
    No, you are not. I don't expect newbies to understand - the argument 'I want as many possible answers' is perfectly valid but from a responder perspective there is 'I don't want to spend time working on providing a solution that has already been provided'. Time is given voluntarily and freely and most don't like to see time wasted. Couple this with the number of regular responders with an in depth knowledge of access/vba is relatively small - not counted but would suggest perhaps less than 100 worldwide - although I am sure there are many thousands of users with in depth knowledge but they don't use the forums (at least to help others). So it comes down to common courtesy which is what the link provided explains. The generally standard notification of 'cross posted here' with a link is to advise responders, potential or otherwise, and not an admonishment to the OP.
    I am new here, I don't usually use forums at all, I don't usually use access or databases, I am a server and desktop support analyst by trade.

    Sent from my SM-N950F using Tapatalk

  6. #21
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,941
    I am new here, I don't usually use forums at all, I don't usually use access or databases, I am a server and desktop support analyst by trade.
    no need to apologise again, apology has been accepted. Understand and apply the etiquette and move on.

  7. #22
    cwager990 is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Posts
    16
    Quote Originally Posted by Ajax View Post
    no need to apologise again, apology has been accepted. Understand and apply the etiquette and move on.
    Fair point, the suggestion made by JSR gets me the view I want, is there anyway to generate the same result but have the query editable ?

    I will need to create some examples for you if you want files as I can not use the live customer data.

    I will set up an example Database, now while I wait for any ideas.

    Thanks All.

    Sent from my SM-N950F using Tapatalk

  8. #23
    JSR is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2018
    Location
    Reno, NV
    Posts
    41
    Create a table "temp last purchase dates" with Customer ID and Last Purchase Date. Primary key is Customer ID and Last Purchase Date.

    Create three queries:

    1) delete all rows from temp last purchase dates
    2) append query based on the purchase table, append to the temp table, group by Customer ID, Max([Date of Purchase]) as Last Purchase Date
    3) select query based on three tables, customers and purchases joined by Customer ID, and the temp table joined by Customer ID and Date of Purchase = Last Purchase Date. Output all fields you want to see.

    This should be editable (because primary key of temp table is customer ID and last purchase date) but slightly less convenient, because you need to run three queries. You can create a macro to run all three. I don't know of a way to have a select query do this type of thing and be editable.
    Last edited by JSR; 09-16-2018 at 03:45 PM. Reason: corrections

  9. #24
    JSR is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2018
    Location
    Reno, NV
    Posts
    41
    dup; made corrections above

  10. #25
    cwager990 is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Posts
    16
    Quote Originally Posted by JSR View Post
    Create a table "temp last purchase dates" with Customer ID and Last Purchase Date. Primary key is Customer ID and Last Purchase Date.

    Create three queries:

    1) delete all rows from temp last purchase dates
    2) append query based on the purchase table, append to the temp table, group by Customer ID, Max([Date of Purchase]) as Last Purchase Date
    3) select query based on three tables, customers and purchases joined by Customer ID, and the temp table joined by Customer ID and Date of Purchase = Last Purchase Date. Output all fields you want to see.

    This should be editable (because primary key of temp table is customer ID and last purchase date) but slightly less convenient, because you need to run three queries. You can create a macro to run all three. I don't know of a way to have a select query do this type of thing and be editable.
    I'll give this a go thank you

    Sent from my SM-N950F using Tapatalk

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 03-23-2018, 01:21 PM
  2. Code to return 'No Record exists'
    By coach32 in forum Programming
    Replies: 2
    Last Post: 07-28-2015, 07:29 AM
  3. Replies: 12
    Last Post: 05-30-2014, 07:08 AM
  4. Report Code is not allowing return to main code
    By rcwiley in forum Programming
    Replies: 2
    Last Post: 06-16-2013, 10:31 AM
  5. Code to add multiple records
    By rachello89 in forum Programming
    Replies: 1
    Last Post: 06-25-2012, 10:04 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