Last record in the Table

Lanason

Registered User.
Local time
Today, 22:37
Joined
Sep 12, 2003
Messages
258
I have "total" query that finds the last number in a table and it has just one field in the table - so when I create anew record i want to look up the last no then add one and then create a new record. The code works in onw query but not in another - - - any ideas guys?


Dim stDocName As String
Dim stLinkCriteria As String
Dim NewStationeryNo As Double

' ------------------------------find last No

NewNo = DCount("*", "qryStationeryLastNo")

NewStationeryNo = DCount("*", "qryStationeryLastNo") + 1
MsgBox "New no " & NewStationeryNo
 
you say

i want to look up the last no
but you are using dcount

Also, data is unordered in databases so there is no such thing as 'first' or 'last' without specify an order
 
My query alredy does the search and has one record with one field in it to determine the last number - that bit works fine.

What I'm trying to do is to get that number out of the query
 
in that case, use

DLookup("lastnum", "qryStationeryLastNo")
 

Users who are viewing this thread

Back
Top Bottom