+ Reply to Thread
Results 1 to 3 of 3

Thread: How to implement LIFO and FIFO method

  1. #1
    Newbie anantabd is an unknown quantity at this point
    Join Date
    Oct 2007
    Posts
    1

    Lightbulb How to implement LIFO and FIFO method

    Dear all i am using ms access database and VB in front end. How i will implement FIFO and LIFO method in inventory. Please give me the database structure and logical process.

  2. #2
    Learning Programmer kkelly is an unknown quantity at this point kkelly's Avatar
    Join Date
    Sep 2007
    Posts
    50
    If you use an Autonumber field as the primary key in a table you could retrieve the first and last record either with the first and last aggregate functions or the min and max functions on the primary key. Like:
    Code:
    SELECT FIRST(ID)
    FROM myTable
    ORDER BY FIRST(ID);
    or
    Code:
    SELECT MIN(ID)
    FROM myTable;
    If your database requires a time/date stamp then the min and max functions on the time/date field would work. Like:
    Code:
    SELECT MIN(DateTimeField)
    FROM myTable;
    Note that the above SQL only returns the value of a single field.

    Another way you could write the SQL to return more than just a single field is with the TOP function. To get the first record:
    Code:
    SELECT TOP 1 *
    FROM myTable
    ORDER BY ID;
    To get the last record:
    Code:
    SELECT TOP 1 *
    FROM myTable
    ORDER BY DateTimeField DESC;
    You could make two queries. One called GetFirstAsset and one call GetLastAsset, then execute these queries (Stored Procedures) from the Visual Basic code.

  3. #3
    Learning Programmer kkelly is an unknown quantity at this point kkelly's Avatar
    Join Date
    Sep 2007
    Posts
    50
    Also, I just wanted to mention that it is best to avoid compound SQL statements. A well structured database really has no need for them, and they can be prone to SQL injection.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

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