Solved

Access query

Posted on 2001-06-17
6
405 Views
Last Modified: 2010-05-18
Hi,

Here I m giving Structures of Tables n some dummy records.

Table Open_stock
----------------
ScriptName          Text
Customer            Text
Stock_date          Date
Qty                 Number
Price               Number

Table Script
--------------
Short_name          Text
Long_name           Text

Table Customer
--------------
Short_name          Text
Long_name           Text

Table Transaction
--------------
Date                Date
Customer            Text
Script              Text
Tran_type           Text
Qty                 Number
Rate                Number
Amount              Number

        Dummy Records for the Above Tables
************************************************************************
Table Open_stock
-----------------
Script  Customer        Stock_date      Qty      Price
------------------------------------------------------
R       C1              1/4/2000        200      35.00
A       C2              1/4/2000        100      40.00
V       C3              1/4/2000        100      45.00

************************************************************************
Table Script
-------------
Short_Name  Long_Name
-----------------------------------------------------
R                 Rr
A                 Aa
T                 Tt
************************************************************************
Table Customer
--------------
Short_name     Long_name
------------------------------------------------------------------------
C1             Abcd
C2             Bcde
C3             Cdef
************************************************************************
Table  Transaction
-------------------
Date     Customer Script  Tran_type   Qty  Rate    Amount
---------------------------------------------------------
09/5/00  C1       R       Purchase    200  35.00  7000.00
09/5/00  C1       T       Purchase    100  30.00  3000.00
10/6/00  C2       R       Purchase    100  40.00  4000.00
15/6/00  C1       R       Purchase    300  40.00 12000.00
05/7/00  C1       R       Sales       200  45.00  9000.00
12/7/00  C1       R       Purchase    100  40.00  4000.00
15/7/00  C1       R       Sales       300  55.00 16500.00
23/7/00  C2       A       Purchase    100  40.00  4000.00
25/7/00  C3       T       Sales       100  50.00  5000.00
31/7/00  C3       R       Purchase    200  50.00 10000.00
15/8/00  C1       R       Sales       200  65.00 13000.00
25/8/00  C1       R       Purchase    100  50.00  5000.00
15/9/00  C2       R       Sales       100  55.00  5500.00
************************************************************************

These are the Table Structure n Records.

I want FIFO Query in Access.

Please Reply me ASAP.

Thanx,

Tejas
 
0
Comment
Question by:teju
6 Comments
 
LVL 7

Expert Comment

by:Nosterdamus
Comment Utility
Hi teju,

1. What do you need the query to do?
It can CREATE a new table, it can UPDATE an existing one, it can just SELECT items from a table and display it on screen through a Form or Report etc,.

2. What is the field that should be used to determine the FistIN (for the FIFO)? Is it field Date from Table Transaction?


Nosterdamus
0
 

Expert Comment

by:DevAlex
Comment Utility
Hi Tejas,

Whenever I get really complex queries I try to break them down into easier to manage sub-steps.  To do FIFO you'll need a date & time stamp - so you'll know which one to grab (or you could use the record # since they are in sequence too).  {To everyone reading this FIFO means First In First Out}.

Often I'll create a query that queries another query (& even sometimes queries it yet another time to get to the solution I want).

OR if you feel more comfortable (seems like your doing a lot - making this the right answer) --> Create an Access VBA function or sub that goes through step by step creating your answer (ie, build a table with the answer set then you can do a simple query to that).  I've found this to be the easiest way to handle these types of things.

Rgds,
DevAlex
0
 

Author Comment

by:teju
Comment Utility
I want answer in this format.
for ex time period is 1/7/00 to 31/7/00.

Date       Script     Qnt     Rate      Amount
31/07/00   R
31/07/00   T
31/07/00   A
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 7

Accepted Solution

by:
Nosterdamus earned 80 total points
Comment Utility
Hi teju,

To get this:

Date       Script     Qnt     Rate      Amount
31/07/00   R
31/07/00   T
31/07/00   A

Use,

QueryTrans:
SELECT Transaction.Date, Transaction.Script, Transaction.Qty, Transaction.Rate, Transaction.Amount
FROM Transaction
WHERE Date >= #07/01/00# AND Date <= #07/31/00#
ORDER BY Date;

Note that the date format is mm/dd/yy. You should use this format even if your regional settings are set to something differen (e.g. dd/mm/yy).

Hope this helps,

Nosterdamus
0
 

Expert Comment

by:amp072397
Comment Utility
teju hasn't logged in since the date of Nosterdamus' last comment. Points will be awarded to Nost' in about 7 days unless teju returns with a viable objections.

thanks!
amp
community support moderator
0
 

Expert Comment

by:amp072397
Comment Utility
(I need a script for this)

Points to Nost'.
amp
community support moderator
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now