Acess Report - Sum the Value of a Field If the value of another Field Matches Criteria - sum

I have an Access Database and i'm trying to create a report that has me a bit stumped. Basically this report is going to display each employee's order processing performance based on a user specified date range, the report gives an itemized detail of each unique product on the order and it's price and Quantity.
Each Product has an 'Assembly Category' either 'DRFLUSH' or 'FRAME'.
In the summary of each Order i want to total the Quantities of each Assembly Category in a separate field.
Initially i rushed this report and have now found that the way i intended on completing this task is incorrect as the value given is only a Count of how many times an instance of each value 'DRFLUSH' or 'FRAME' occurs. I started with as follows: (Please ignore the bad practice with field naming i have taken this database on from a previous employee).
=Count(IIf([ASSEMBLY ITEM CATEGORY]="FRAME",1,Null))
And
=Count(IIf([ASSEMBLY ITEM CATEGORY]="DRFLUSH",1,Null))
However as previously stated this is wrong. I want the fields to sum the Quantity of each line item but only where the criteria is matched.
Any help is greatly appreciated, i'm sure this is a ridiculously simple task however i just cannot seem to wrap my head around it today.
Thanks
Alex

Sorted this by changing the statements to as follows:
=Count(IIf([ASSEMBLY ITEM CATEGORY]="FRAME",[QTY],Null))
=Count(IIf([ASSEMBLY ITEM CATEGORY]="DRFLUSH",[QTY],Null))

Related

MS Access manual Auto incrementing field

Im building a system for my company to keep track of internal orders, inbetween our warehouses, we have material that goes out warehouse 1 to warehouse 2 and we kind of lose track of how much of "x" is in warehouse 1 and how much in warehouse 2, so i want to implement this access db where a user fills a form and says: order 1: 500 of "x" order 2: 300 of "y". then another user fills an exit form where he says 1 of "x" going out, so i would need the program to keep track of total order and how much as gone out to fill order 1 and so on...
My idea here is to have both an order number and an id number for each of "x" everytime someoneone assembles 1 "x" they fill the form and print a label directly from the access (i have this part working already) while keeping a record of when it was assembled, who verified and what was verified (it will work as a quality control also).
What i dont know is how to program the db so when it reaches 500 of "x", the id number for "x" starts again from 1
This is the one major issue with my program right now, i'm not experienced in access db's or vba, but im getting there with a tip and a trick from here and there, so, no need to be careful with the technical language, i will google it if i have to :p
EDIT:
The table structure goes as follows:
1 table as the main table where I record the check that is made for every product, where I include the model of the product, the said ID that I want to reset after a number of products checked, and a concatenated field that includes most of this information to generate a qr code.
Then there is a table for the Order Number, which is connected to a form to record each new order with a date/time field, the order number itself and the number of products. This number of products must then be called from the code that will count how many products have been checked to date and keep the order number field updated so we can keep track of the order.
Then there is another minor table just to get values for the form, the product models
Thank you for your answers ;)
See this MSDN Documentation
Unfortunately in Access, you cannot 'reset' an ID field, unless you move the records to a newly created table and use that table for every 500 records.
As for the user control and login form, I'm afraid those are separate questions that must be asked in a different thread.
To get you started:
You can set the RecordSource of a form to a table, and when users make entries, the data will be saved to the table. You can also use a form with controls (text boxes, comboboxes, etc.) and create a button that runs a query to insert these records into a table.
The login piece - you can encrypt the database with a password. That may/may not be sufficient.
I would suggest you change your schema, if possible. Something like the following:
Orders
OrderID (Autonumber)
ProductID (link to your Products table)
QuantityRequested
Deliverables
DeliverableID (Autonumber)
OrderID (link to your Orders table)
SequenceNumber: in the BeforeInsert event set this value equal to:
DCount("*", "Deliverables", "OrderID=" & Me.OrderID) + 1
I'm assuming that your form has a control named OrderID that is bound to the OrderID field of the Deliverables table.
The code uses the DCount() function to get the count of all the other deliverables that have already been created for this order. If this is the first deliverable, DCount() will return 0. It then adds 1 to this count to get the sequence number of the next deliverable.
If the new SequenceNumber is greater than the quantity requested, you could display a message saying that the order has been filled and cancel the creation of the Deliverable record.
This is just one approach and it is not a complete solution. I'm assuming that once assigned a sequence number a deliverable cannot be deleted. You might need to make allowances for deliverables that get lost or damaged. You could incorporate a status field to the Deliverable table to deal with this, but you would still need to make a decision about what to do with the SequenceNumber.

Specific info on access report

Probably get shot for posting this again but last attempt was put on hold so sorry in advance. i am very new at this so apologies if its a simple answer;
I created a table with name of purchaser, items purchased, date of purchase and cost of purchase. From that i wanted to create a report that would show each purchasers name only once with a combined total cost of all purchases.
I created a query that did just that using only the purchasers name and the total cost of their purchases. I then created the report from that query.
The report shows each name once with a total cost of purchases which was great except for the query continually adds those total purchases without the ability to select a date range and likewise the report shows the same info.
When i add the purchased date to the query/report so i can filter between 2 date ranges it then shows each name "X" amount of times with a total for each purchase made which is not what i am looking for as this ends up with a long report.
Hope this makes more sense than my last attempt at this question. I am very new at this so a simple answer would be great.
Thanks in advance
You need to get two parameters for the query, say [Start] and [End].
You need to add the date column twice so that it can be compared to [Start] AND [End]
You need to add the date column (on both occasions) with a Total "Where"; this tells access that the column has no other purpose than to impact a WHERE-constraint on the base dataset.
If you run into trouble, take the SQL below, correct all names in it, paste it into the query's SQL view, and then see what the design view looks like!
SELECT table.customer, Sum(table.price) AS sum
FROM table
WHERE (((table.date)>=[Start]) AND ((table.date)<=[End]))
GROUP BY table.customer;

VBA, SQL, Queries

I have an access form with few controls on it, like start-date, end-date, move_type, mover_name etc, when user fills this field n clicks on query command button, a select query is run and it fetches records from various tables depending upon the criteria mentioned by the user.
Later the same records are exported to excel file and a report is generated for user.
Now I need to do more with this, my select query has a field "quoted-price", depending upon the price quoted the records need to be sorted out.
EX : if quoted_price < 500 then it is a "domestic apartment1", if quoted-price is >500 And <1500 it is "domestic Apartment1" etc.
Now I need to do more with this, my select query has a field "quoted-price", depending upon the price quoted the records need to be sorted out.
EX : if quoted_price < 500 then it is a "domestic apartment1", if quoted-price is >500 And <1500 it is "domestic Apartment1" etc. and when all the records generated through select query are searched on this criteria, the records need to be grouped accordingly. Later the count for individual category is multiplied by a unit value and total charge is calculated.
I tried building many queries to do this and tables to refer to value but of no use. Any help will be much appreciated.
are you looking to create a new field depending on the condition? That may be step one of what you are trying to do, If so that is pretty easy. See here: http://allenbrowne.com/casu-14.html

SQL query in Access

Basically, I've been trying to make this query work for a while in Access and it's really frustrating me so instead of playing around with the criteria, I've decided to just do it in SQL instead but I can't quite figure out how to do this bit.
What I need to do is create a query that shows which members haven't returned an item that they're currently taking out on loan. If possible I'd like to include a calculated field to state the date is was due back and how many days late it is.
The fields I'm using are as follows;
Table = Loan
Toy Name
Hire Date
Duration (in days)
Returned Date (if it hasn't been returned, the cell is blank)
Table = Toy
Purchase Price
Hire Price
you wrote:
a query that shows which members haven't returned an item
your table does not have members in it. secondly table toy have nothing related to toy like toy name or something. Please provide further detail of tables.
one more question what is the meaning of blank? Is it Null or blank string?

MS Access tables that need to be in the listbox

OK, I have the worst VB class in the world. The friggin textbook has you do programming projects but the stupid book doesn't even explain everything required for the project. Oh yeah, the professor for the class doesn't help worth a crap (online schooling).
So needless to say, I have been struggling with the class for a very VERY LONG TIME...
Well, here's my request:
Here is visual representation of what is required
Now, I have been fighting this thing for MANY MANY hours and would like some tips and advice on how to get this stupid thing done. I usually get more specific when it comes to posting in this website except this time, it seems like I have a problem with EVERYTHING!!!
Here is the instructions:
"The database Microland.accdb is maintained by the Microland Computer Warehouse, a mail-order computer-supply company. The tables below show data in the three tables in the database. The table Customers identifies each customer by an ID number and gives, in addition to the name and address, the total amount of purchases during the current year prior to today. The table Inventory identifies each product in stock by an ID number and gives, in addition to its description and price (per unit), the quantity in stock at the beginning of the day. The table Orders gives the orders received today. Assume that it is now the end of the day. Write a Visual Basic program that uses the three tables to do the following two tasks:
Display in a listbox the items that are out of stock and those that must be reordered to satisfy today’s orders.
Display in a listbox bills for all customers who ordered during the day. Each bill should show the customer’s name, address, items ordered (with costs), and total cost of the order.
So, if any of you VB geniuses would like to tell me how to do some of this stuff, that would be absolutely awesome. Any kind of help will definitely make a difference for me.
(I'm assuming it's VB.NET) Here's some pointers on the bigger picture, you'll need Google to fill-in the details:
1) Establish a connection to your Access database using ADO.NET. Maybe do this in code or use the data tools in Visual Studio?
2) Write a query (in Access or plain SQL) to find the count of the distinct stock items that have been purchased today and subtract that from the count of the items in stock at the beginning of the day. Select the items where the count is zero or less.
You can use the visual builder in Access and save the query object, referring to this query object in code. Or you can copy the SQL generated by Access and use this with ADO.NET command objects.
3) Show the results of this query in a listbox. Either step through the DataReader adding items to listbox in code, or investigate databinding to your datasource.
4) Write another query that shows the data requested in step 2 in your question and then list those results in another listbox.
Try to get a little further with it and then respond with progress and further issues.