Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2002
    Posts
    21

    Unanswered: storing the value of a query

    I have the following query which finds the max record number (I want to increment it by 1 using custom logic):

    SELECT max([OrderID])
    FROM Orders;


    How can I assign the return value of this query to a string variable in code?
    ie. MaxRecordNumber = "SELECT max([OrderID]) FROM Orders;"

    tia flynn

  2. #2
    Join Date
    Jan 2003
    Location
    Rockville, MD
    Posts
    179
    A perfect use for the DMax domain aggregate function
    Code:
    MaxRecordNumber = DMax("OrderId", "Orders")
    Or use this, so it doesn't crash on an empty table (assuming MaxRecordNumber is a long integer)
    Code:
    MaxRecordNumber = Nz(DMax("OrderId", "Orders"), 0)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •