Microsoft Access Auto Rounding an Average Value from a query - sql

I'm very new to Microsoft Access and I've run into a bit of a conundrum. I'm building a basic Access database that can help my Dad use past invoices to quote future jobs. I really only have two objects I'm working with. An invoice Table that hold all the costs that we paid for specific metals in 2013 and a Form I'm making that pulls information from that table. In my basic table I have a Currency field called PPLB(Price Per Pound). Now throughout the year we sometimes buy the same metal multiple times and if you know anything about metal, you know that the amount of metal you purchase sometimes affects the price that you pay. So in my Quoting Form I have a Query that looks like this->
SELECT DISTINCTROW Avg(MAT_QuickBookInvoices_2013.PPLB) AS [Avg Of PPLB]
FROM MAT_QuickBookInvoices_2013
GROUP BY MAT_QuickBookInvoices_2013.Material, MAT_QuickBookInvoices_2013.[Material Subtype], MAT_QuickBookInvoices_2013.Spec, MAT_QuickBookInvoices_2013.Shape, MAT_QuickBookInvoices_2013.Sizes
HAVING (((MAT_QuickBookInvoices_2013.Material)=[Forms]![MAT_QuoteTable]![Mat_CB]) AND ((MAT_QuickBookInvoices_2013.[Material Subtype])=[forms]![MAT_QuoteTable]![SubType_CB]) AND ((MAT_QuickBookInvoices_2013.Spec)=[forms]![MAT_QuoteTable]![Spec_CB]) AND ((MAT_QuickBookInvoices_2013.Shape)=[forms]![MAT_QuoteTable]![Shape_CB]) AND ((MAT_QuickBookInvoices_2013.Sizes)=[forms]![MAT_QuoteTable]![Size_CB]));
I know that's long but what it's doing is grouping the different type of metals into their most common grouping using Combo Boxes in the Quote Form and then finding the average price for that group. So now the problem. When I run the query it pulls up the correct price but when it transfers to the combo box it rounds price to the nearest whole dollar. How can I change or correct this? I've tried changing and formatting the source table as a double instead of currency and this hasn't helped. Any hints at all would be appreciated.

On the Property sheet for your comboBox, set the Formay property to Fixed. Then. immediately underneath that, set the number of decimals to 2 or 3 or whatever. That should do it.
Cheers -

Related

Libreoffice Base - Triggering stock table deductions from orders table

I'm working on a DB that consists mostly of two tables. One with our stock of memorial markers, and the other where I keep a running list of ongoing and completed orders.
When I change an ongoing order in the Orders table to completed I would like to have one of the corresponding memorial markers deducted from that size category in the stock table.
I've mostly been building this using the form designer and wizards but I am comfortable with coding, though I'm not super familiar with SQL. Some pointers in the right direction should to get me going should help. I've been searching around but keep getting results for other things.
Thanks for your time

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

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))

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;

How to Query for Due Dates in Access 2007

I have a 2 access 2007 tables with the following fields:
Table 1: Loan Release Table
ReleaseDate as Date
Maturity as Date
MemberName as Text
MemberNo as Text
Term (in months) as Number
Mode (M/Q/Semi-Monthly) as Text
LoanType as Text
LoanAmount as Currency
LoanCode as Text
Table 2: Payments Table
ReceiptNo as Text
DatePaid as Date
MemberName as Text
MemberNo as Text
LoanCode as Text
LoanReceivable as Currency
InterestPaid as Currency
I would like to ask on how to use Query to create a temporary table that will display Members that should pay on current date or a specified date base on their Term, Mode of Payment and Loan Type (Regular Loans every 30 days to pay, Special Loans every 45 days to pay) and their remaining balance.
Here's my First Attempted Query: I tried to subtract 30 days from Current Date and it obviously gave me just the transactions last month. I would like it to list all transactions including those for example Member with Regular Loan 12 month term on their 3rd monthly payment, Member with Special Loan that is due today.
I am thinking of creating another table that contains the schedule of payments of every Loan released and then go from there.
Is there another way than this? Like a Query that can be run everyday without the need for a bulky ScheduleOfPayments table?
I'm an office clerk who 'graduated' from Excel and a novice using Access at worst and I'm not afraid of VBA codes if that is necessary.
If you know of a better way of doing this, please do tell me or point me in the right direction. I'm all for learning new things and having read and learned a lot from stackoverflow before, I am sure that with your help, my question is as good as solved.
Thank you guys for reading my inquiry.
You have here two solutions:
You can write a procedure that will, when needed, calculate\generate a matrix containing payment schedule for each loan and compare it to payment done.
You can write a procedure that will, when a loan is created, generate corresponding records in a payment schedule table. further comparison will be done between the ScheduledPayment table and the Payment table.
So basically you have to manage a similar set of data, either as a calculated/on the fly matrix or as a permanent set of data kept in a table.
The second version is by very very far the most effective one. You think of it as bulky but it is exactly the opposite, and indeed what is done every time you get a loan from a bank, where your banker will let you sign the reimbursement schedule.
The table solution will allow you to make use of all querying facilities, while the calculated solution will force you to write specific procedures each time you'll want to do some data mining. Just think about a question like "What are the expected reimbursements for the month of April 2014?". Answering this question with the ScheduledPayment table will be as easy as getting a cafe out of your nespresso machine. The same answer without the ScheduledPayment table will be like having to do the whole coffee production process before getting your cup ready.

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.