Solved

Access query

Posted on 2001-06-17
6
442 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 7

Expert Comment

by:Nosterdamus
ID: 6199955
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
ID: 6200102
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
ID: 6209099
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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 7

Accepted Solution

by:
Nosterdamus earned 80 total points
ID: 6209614
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
ID: 6742555
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
ID: 6758970
(I need a script for this)

Points to Nost'.
amp
community support moderator
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

697 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