473,795 Members | 3,323 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Query on month

I'm a newbie to Access and am having trouble understanding the logic
behind queries. I have 2 tables, 1 for stock in and 1 for stock out. I
have joined these in a union query. the fields I have are:
Month
Stockpile
Stock type1
Stock type2
Stock type3
Stock type4

What I want to do is produce a query that gives me a monthend stock
figure for each stockpile (without all the detail).

Thanks for any help

Max
Nov 13 '05 #1
2 1372
MAX SMITH wrote:
I'm a newbie to Access and am having trouble understanding the logic
behind queries. I have 2 tables, 1 for stock in and 1 for stock out. I
have joined these in a union query. the fields I have are:
Month
Stockpile
Stock type1
Stock type2
Stock type3
Stock type4

What I want to do is produce a query that gives me a monthend stock
figure for each stockpile (without all the detail).

Thanks for any help

Max


Try looking up crosstab queries in Help.

Nov 13 '05 #2
Max,

The problem you are having is that your tables are designed incorrectly! Also
you only need one stock table, not two. Try these tables:

TblStock
StockID
StockTypeID

TblStockType
StockTypeID
StockType

TblStockTransac tionType*
StockTransactio nType
Mutiplier

TblStockTransac tion
StockTransactio nID
StockID
Month
StockTransactio nType
TransactionQuan tity

*StockTransacti onType In, Multipiler 1; StockTransactio nType Out, Multipiler -1

You need a form/subform to enter StockTransactio ns. The main form is based on
TblStock and the subform is based on TblStockTransac tion. In the subform, you
use a combobox to select the StockTransactio nType (In or Out) and then enter the
TransactionQuan tity. TransactionQuan tity is always entered as a positive number.
The combobox is based on TblStockTransac tionType. BoundColumn =2, ColumnCount =
2, ColumnWidths = .75;0.

To get the inventory of any stock at any time, you need a query that includes
TblStock, TblStockType, TblStockTransac tionType and TblStockTransac tion. Include
the following fields:
StockType 'TblStockType
Month 'TblStockTransa ction
Transaction:[StockTransactio nType]*[TransactionQuan tity] 'Calculated Field
**

Enter the following expression in the criteria for Month:
<=[Enter Month]

Change the query to a totals query. Where it says GroupBy under Month, change to
Expression. Where it says GroupBy under Transaction, change to Sum.

** StockTransactio nType actually has the value of Multiplier (+1 or -1). So in
this calculated field, you are multiplying +1 times Quantity for In Transactions
and -1 times Quantity for Out Transactions.
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdata sheet.com
www.pcdatasheet.com


"MAX SMITH" <MA*********@HO TMAIL.COM> wrote in message
news:bb******** *************** ***@posting.goo gle.com...
I'm a newbie to Access and am having trouble understanding the logic
behind queries. I have 2 tables, 1 for stock in and 1 for stock out. I
have joined these in a union query. the fields I have are:
Month
Stockpile
Stock type1
Stock type2
Stock type3
Stock type4

What I want to do is produce a query that gives me a monthend stock
figure for each stockpile (without all the detail).

Thanks for any help

Max

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1599
by: colmobrien | last post by:
Help Needed ms access 2000 I have a table where one field is the year end monthr (January, February,........, December) and another field is the year end day (1,2,3,........,31) i want to create a query which gets the month and date and returns all records where Year end month = user input (eg April) and year end day <= user input (eg 5)
1
3067
by: ED | last post by:
I currently have an ODBC query that hits an Oracle database. I want to bring back records for a given month based on a job completion date in the Oracle database. I would like to have the user define what date range that is, restricting to a month period. I do not want to have to have to develop a lookup table for month and year. I was wondering how I could use a calendar function or something similar to populate the month and year in...
13
5847
by: Sue | last post by:
I'm working on a database that keeps track of employees hired by a general contractor on a project by project basis. These employees are hired to work on a project and are then laid off either at the end of the work they were hired to do or at the end of the project. Any employee may be hired, laid off and rehired several times during the course of time. The tables I have and the critical fields to my question are: TblEmployee EmployeeID...
6
17924
by: Tony Miller | last post by:
All I have an aggregate query using the function Month & Year on a datereceived field ie: TheYear: Year() TheMonth: Month() These are the group by fields to give me a Count on another field by year & month When I try to place a date filter 'Between x And y ' on an expression field
22
31213
by: Stan | last post by:
I am working with Access 2003 on a computer running XP. I am new at using Access. I have a Db with a date field stored as mm/dd/yyyy. I need a Query that will prompt for the month, ie. 6 for June, and will return all records in that month.
2
1558
by: =?Utf-8?B?RGlmZmlkZW50?= | last post by:
Hello All, I am trying to construct an XPath query against an XML document, for a requirement that I have. Below is the XML fragment: <SUBMISSIONS> <SUBMISSION YEAR="2004"> <MONTH NAME="JAN">10</MONTH> <MONTH NAME="FEB">02</MONTH>
5
3847
by: wugon.net | last post by:
question: db2 LUW V8 UNION ALL with table function month() have bad query performance Env: db2 LUW V8 + FP14 Problem : We have history data from 2005/01/01 ~ 2007/05/xx in single big table, we try separate this big table into twelve tables and create a view
9
4025
by: JJM0926 | last post by:
I'm trying to create a running totals query in access 97. I have followed the directions on how to do it from Microsofts website article id 138911. I took their code they had and replaced it with my fields. When I try to run it I get #errors in my RunTot column. I'm kinda new to this. Not sure if maybe I mistyped something wrong or is there a better way to do this? I have pasted the code. Any help would be greatly appreciated....
11
1846
by: Stan | last post by:
I am using MS Office Access 2003 (11.5614). I have been running the following query with good results. The query lets me enter the month period and returns the SUM of the age fields. SELECT AS , SUM() AS , SUM() AS , SUM() AS , SUM() AS FROM WHERE FORMAT(,"mm/yyyy")=; I now want to add an additional criteria of the city field. I added
4
4589
by: zion4ever | last post by:
Hello good people, Please bear with me as this is my first post and I am relative new to ASP. I do have VB6 experience. I have a form which enables users within our company to do an intranet reservation of available resources (laptops, beamers, etc). The MySql database queries are already in place, as is the ASP administration panel. The frontend that users will see however, still needs some work. I'm really close, but since I'm no...
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10435
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10213
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10163
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9037
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6779
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.