Gustav Brock
Gustav at cactus.dk
Fri Sep 5 01:37:15 CDT 2008
Hi Kath I guess you could and should use DMin without any issues: NextItemID = DMin("ID","qryMyFormQuery","[Name] > '" & [Name] & "'") It will sort "correctly", that is the default sorting of your database. If you need any other sorting the plot thickens. /gustav >>> kp at sdsonline.net 05-09-2008 04:33 >>> Your solution is nice and simple but think it is going to get me into all kinds of problems when I hit names (workplacenames) with strange characters and apostrophes in them. And if I use code to handle the apostrophes (replace them etc.) then the statement won't work. hhmm.. ----- Original Message ----- From: "Stuart McLachlan" <stuart at lexacorp.com.pg> To: "Access Developers discussion and problem solving" <accessd at databaseadvisors.com> Sent: Friday, September 05, 2008 12:01 PM Subject: Re: [AccessD] Next, Prev > NextItemID = > Dlookup("ID","qryMyFormQuery","[Name] > " & [Name]) > > > Incidentally, it's very bad practice to use "Name" as a field name - it can bite you in all sorts > of ways. > > > On 5 Sep 2008 at 10:51, Kath Pelletti wrote: > >> Must be the week for working on Next, Prev functions on the list............ >> >> This is a bit of an odd situation, but what I have a continuous form >> which displays names and ID's. It's source is a query which is sorted by >> the Name field. >> >> In another area of the application, I need to be able to know the ID of >> the 'next' rec in that continuous form. >> >> eg. Continuous form shows: >> Name ID >> AAB 90312 >> AAC 23 >> AAD 845 >> AAE 32 >> >> If I have a form for AAB open, I need to get the ID of the next item AAC, >> which is 23. >> >> Maybe I am making this too hard, but the fact that the list is >> alphabetically sorted has me thrown............... >> >> tia >> Kath >> >> ______________________________________ >> Kath Pelletti >> Software Design and Solutions Pty Ltd >> kp at sdsonline.net