vba - SQL query search by ID and get another attribute of the record -


i'm working on db need search max(id), id autonumber, (basically recent record/last record) , when found want receipt number. e.g.

receipt table

id         date        number 2          ###          1423 3          ###          1452 4          ###          1401 

i'm retrieving max(number) due program requirement, recent not highest. want retrieve highest id value value of number increment. tried nested queries no results. although i'm familiar vba, i'm not complex queries , optimization.

you use dmax maximum id value table. example, in immediate window ...

? dmax("id", "yourtable") 

you can use expression in query ask row highest id value.

select y.id, y.date, y.number yourtable y y.id=dmax('id', 'yourtable'); 

but dmax access-specific. if want approach portable other databases can use subquery retrieve highest id value.

select y.id, y.date, y.number yourtable y y.id=(select max(id) yourtable); 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -