I'm bug fixing a query that is 99.99% correct.
It consists of three tables built using the query design option in access.
The driving table is client order table. This is linked to the client table to pick up client specific data and also a payments table which tracks when payments were made against the order. This obviously can contain many rows to the order. One of the fields on this table is a date due field. This is when the next payment is due. This field is empty when the order has been paid in full.
The idea that the last (chronologically) of the payment rows will contain either the next payment date or spaces to show it's been paid.
The query is basically grouped on order number and the query uses "last" for date of payment with the idea it will, as above, display a date or be blank for payment in full (i.e. no next payment due date).
This seems to work for some orders and not others
For one such that doesn't work it has 3 payment numbers. I'm going to show this with the fields and autonum (I know we shouldn't rely on autonum but just using this to show something I've spotted.
Now with the query using "Last" I was expecting the row with autonum of 17453 to be picked up. In actual fact 17384 is picked up.
Now if I look at the payments table and set the filter to be equal to CLient1OrderX I get the 3 rows above but in the order of
17453
17385
17384
How can I ensure I always pick up the last record
Hope all this makes sense
It consists of three tables built using the query design option in access.
The driving table is client order table. This is linked to the client table to pick up client specific data and also a payments table which tracks when payments were made against the order. This obviously can contain many rows to the order. One of the fields on this table is a date due field. This is when the next payment is due. This field is empty when the order has been paid in full.
The idea that the last (chronologically) of the payment rows will contain either the next payment date or spaces to show it's been paid.
The query is basically grouped on order number and the query uses "last" for date of payment with the idea it will, as above, display a date or be blank for payment in full (i.e. no next payment due date).
This seems to work for some orders and not others
For one such that doesn't work it has 3 payment numbers. I'm going to show this with the fields and autonum (I know we shouldn't rely on autonum but just using this to show something I've spotted.
| "Autonum" | "Date Next Due" | Client Order Reference |
| 17384 | 10/1/2026 | CLient1OrderX |
| 17385 | 13/1/2026 | CLient1OrderX |
| 17453 | Blank | CLient1OrderX |
Now with the query using "Last" I was expecting the row with autonum of 17453 to be picked up. In actual fact 17384 is picked up.
Now if I look at the payments table and set the filter to be equal to CLient1OrderX I get the 3 rows above but in the order of
17453
17385
17384
How can I ensure I always pick up the last record
Hope all this makes sense
Last edited: