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.
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.
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:
orCode:SELECT FIRST(ID) FROM myTable ORDER BY FIRST(ID);
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(ID) FROM myTable;
Note that the above SQL only returns the value of a single field.Code:SELECT MIN(DateTimeField) FROM myTable;
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:
To get the last record:Code:SELECT TOP 1 * FROM myTable ORDER BY ID;
You could make two queries. One called GetFirstAsset and one call GetLastAsset, then execute these queries (Stored Procedures) from the Visual Basic code.Code:SELECT TOP 1 * FROM myTable ORDER BY DateTimeField DESC;
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.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks