i Have created a query and i want to calculate the order price from the Orders table by the inventory quantity in the Inventory table. How this can be in the design view?
Create your query with the desired fields and the fields you need for the calculation :
Save the query.
Then, right click in an empty field and select Build...
The expression builder will open. All you have to do is supply your expression :
But if you really wantToLearnNewSkills, you should try writing SQL on your own, this isn't even that hard of a statement. Good luck.
Related
I am attempting to combine two groupings(sum), EPL and POL and relabel them as something, say "Other GL". The current output is this. I've attempted adding a formula in the criteria but it is not working. I have also attempted adding another column in the design view with a formula alone.
The best way to "combine" data rows for grouping (i.e. sums) is to create a preliminary query which reassigns the individual source rows to a common value. Then use that query as the source for the other query(ies). (Such a preliminary query could be either a nested query -a.k.a. subquery-, or a saved query. I personally prefer saved queries since they can be edited and viewed using the standard Access Query Designer, whereas subqueries can only be edited as SQL text.)
Without other database schema or SQL statement to work with, all I can show is a SQL snippet showing the altered selection:
SELECT iif(Claims2.Grouping = 'EPL' Or Claims2.Grouping = 'POL', 'Other GL', Claims2.Grouping) As AltGrouping, ...
FROM Claims2
For what it's worth, the same iif() statement could also be inserted directly into the your query as a "calculated field"--within the query designer just copy and paste it into the Field cell in place of Grouping. But a saved query that adjusts labels preliminary to final queries can be reused and makes later queries simpler.
Ok here is my dilemma and I am sure more experienced Access users have an easy solution. I have been manually running a set of queries to pull data for business users, that I want to create a form for so they can just run it themselves. This would be easy if it was one query, but the way I have to pull the correct data is first have to run one query that creates a table. I then use that 'new' table in a secondary query to get the data I need.
That first make table query needs to take inputs like supplier number and date range. I then use that output table in another query that sums up total dollar value of purchase orders. I can not include these two steps in one query as it creates an ambiguous outer join.
Any ideas on how I would go about creating a form for something like this?
Well after re-thinking this I think I was OVER thinking it. Instead of creating a table in the first step, I can just save it as a query and join that query to the second query. Then make a form off the two queries.
I have a table field in which I want to calculate the price of an order. In that table I have a field where you choose what dishes did the client order. And I need to get the prices of those exact dishes from another table and then sum them up. I want to calculate in field SASK and take prices from table VALGIARASTIS. So what should the formula be?
For example in field dish I choose Balandeliai,Bulviniai blynai, Cepelinai formula should take those names and get prices of it from table VALGIARASTIS and sum them up.
Here's a screenshot for you to understand.
The solution will not be a formula. It will be a VBA function that receive an array from the multi-value combo box, uses it to build a filter for the data in the VALGIARASTIS table, and uses an aggregate query to SUM() the price values.
For the first part, you can refer to these links:
http://allenbrowne.com/ser-50.html
http://support.microsoft.com/kb/135546
Once you have the means to filter a recordset, you can run an SQL query on the results using the SUM() function to get your total. You can run a DAO cursor through the recordset and get your total that way, but SQL is better.
I have a database to calculate my expenses. I record expenses with negative numbers, and salary with positive numbers. When I make the month report, and sum the values, it sums it all including salary. I want to code of Visual Basic to sum negative numbers only. I know about Filter property, but the Filter I put disappears when I close database. Can you help me, please?
You can build your report using a query or use the Where argument of the OpenReport method of the DoCmd object in versions of Access since 2003.
EDIT re comment
The easiest way to create a query is to use the query designer, viewed in SQL View, you should see something on the lines of:
SELECT Amount
FROM MyTable
WHERE Amount <=0
To keep this simple, lets say I have two tables.
The first is called Employees. It contains an id field and an employee_name field.
The second is called Pay. It contains an id field, an employee_id field and an amount field.
Now, I want to run a report on Pay that shows me how much each employee got paid by showing me only the Employee.employee_name and the Pay.amount.
Obviously, I'm going to have to take the employee_id field from the Pay table and match it up with the the id field from Employees, but I have no idea how to do that.
I know a little VBA and am pretty knowledgeable with SQL, but MS Access has me so confused I'm about to kill myself. I hate Access so much, I want to take it outside behind the middle school and get it dead.
This seems like a relatively easy problem, so someone has to know how to do this. Any help would be hugely appreciated.
You are looking for a query like this
SELECT Employees.Id,
Employees.employee_name,
Sum(Pay.amount) AS SumOfamount
FROM Pay INNER JOIN
Employees ON Pay.employee_id = Employees.Id
GROUP BY Employees.Id,
Employees.employee_name;
If you wish to make this as part of a list box, you can either save the sql as a query and set the Listbox property under the Data Tab called RowSource to the Saved Query Name, or you can set the sql string as the RowSource.
Remember to have a look at the Properties called Column Count ( something like 0;3;3 0 being to hide the first column ) and Column Heads (to include column headers, default NO )
If you widh to craete a Report using the data, you can go about this the same way ( Saved Query or Use the Sql String ). The Query/Sql String can be set in the Data Tab in the Record Source property. Now you can add the fields to the report from the Existing Fields window.