DLookup

  • Thread starter Thread starter Rusty Rutherford
  • Start date Start date
R

Rusty Rutherford

I'm trying to have DLookup return the second row in a table in report. I've
tried the following but it doesn't work.

DLookUp("[Name]","Table","[AutoNumber] =" & ((SELECT Min(AutoNumber) FROM
Table)+1))

Any suggestions?

Thanks!
 
DLookUp("[Name]","Table","[AutoNumber] =" & _
Nz(DMin("AutoNumber", "Table"),0)+1)
 
Try:
"[AutoNumber]=" & (Dmin("AutoNumber","Table")+1)

Note that Autonumbers are not always incremental: any cancelled "add record"
action or failed append will leave gaps in the sequence, so "+1" is not
reliable.

If you are using code, you would be better off using DMin to get the
smallest value and then use DMin again to get the smallest value that isn't
the first value you found.

OR, create a saved query using TOP & then use DLast() or DMax():

SELECT DISTINCT TOP 2 AutoNumber
FROM Table
ORDER BY AutoNumber ASC

The query will return the first 2 unique AutoNumbers.

To get the last record:

DLast("AutoNumber", "MyQuery")

(Or use DMax)

HTH
 
worked like a charm! thanks
Douglas J. Steele said:
DLookUp("[Name]","Table","[AutoNumber] =" & _
Nz(DMin("AutoNumber", "Table"),0)+1)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Rusty Rutherford said:
I'm trying to have DLookup return the second row in a table in report.
I've tried the following but it doesn't work.

DLookUp("[Name]","Table","[AutoNumber] =" & ((SELECT Min(AutoNumber) FROM
Table)+1))

Any suggestions?

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

DLookup Function 2
DLookup and Nz 0
Validation rule to prevent overlapping time periods 5
DLookUp Returning Primary Key 4
dlookup 2
Get a number from a table to a form. 0
Dlookup 7
DLookup can't find a value 13

Back
Top