First, thank you in advance for your assistance.
I have two tables in MS Access: [BillNotes] which holds notes pertaining to Bill #s and [OpenBills] which holds Bill information.
Question: How can I update [OpenBills] so that the latest note is obtained from [BillNotes] as shown below.
Here are examples of my two tables:
[BillNotes]
BillNumber NoteDate BillNote
1 4/1/2022 Note 1
1 4/2/2022 Note 2
1 4/3/2022 Note 3
2 4/1/2022 Note 1
2 4/2/2022 Note 2
2 4/3/2022 Note 3
3 4/1/2022 Note 1
3 4/2/2022 Note 2
3 4/3/2022 Note 3
[OpenBills]
BillNumber OrderNumber Amount LatestNote
1 101 1000 4/3/2022 - Note 3
2 105 10500 4/3/2022 - Note 3
3 107 200 4/3/2022 - Note 3
Here is the query I have which partially works. It doesn't always get the latest note.
UPDATE [OpenBills] INNER JOIN [BillNotes] ON
[OpenBills].BillNumber = [BillNotes].BillNumber
SET [OpenBills].LatestNote = [BillNotes].[NoteDate] & " - " & [BillNotes].BillNote
WHERE (SELECT MAX([BillNotes].NoteDate) FROM [BillNotes]);
Note: The Update statement I am needing would populate LatestNote in OpenBills. Otherwise, there wouldn't be a value for LatestNote in OpenBills.
NoteDate in BillNotes is a ShortDate
Any help is appreciated. Thank you.