How do I calculate amounts from fields in different tables in Access 2013 - ms-access

I want to keep track of credits/laway/rent to own info.
I have [Clients] table, [Credit] and a child [payments] table, to keep track of payments of multiple credits.
I want to make a Split form where I can see credit details ex. (type, amount of credit, amount of credit currently paid and last amount due) with a record of all payments done on the subform.
Now I ran into blockade when trying to use sum() or Dsum() to calculate the "amount of Credit currently paid" and "amount of credit due" in a text box on the form.
I think I´m missing something in the criteria part for I don´t know how to pass the current creditID key to group and calculate ???
the closest I´ve gotten is =DSuma("[MontoPagado]","Pagos","[IDCreditoFK]") but this adds all up and I really need something like:
"amount due" =[table1]![Field1] - SUM([table2]![Field2]) Based on Current "creditID"
Its a basic credit/layaway plan payments database I hope someone can help for I have spent days with very Little sleep and this is the only thing holding me up...
Download copy here ----> https://mega.nz/#!gp0lSRLA
Thank you in advance!!

He there,
You can use the DSum, but slightly different
=DSum("[MontoPagado]","[Pagos]","[IDCreditoFK]=" & [CreditorID])
Here, [CreditorID] should point towards the CreditorID control on your form

Thank you! Thank you! Verlaat you saved me, I don´t why I can´t grasp the concept or rules of building criterias and expresions?
Finally this worked perfect:
=[TotalDelMonto]-DSum("[MontoPagado]","[Pagos]","[IDCreditoFK]=" & [IdCreditos])

Related

Access 2010 report invoice total

I am trying to do a report invoice and need to give a total cost for each customer invoice, but so far all I am getting is the microsoft #error!
The formular I am using at present is:
=Sum([qry5InvoiceCalculated]![OrderTotal(AU)])
I have tried other formulas, but keep getting the same #error!
What am I doing wrong, or is the a formula that I have not tried yet?
Here is the file, if you would like to take a look at it to see what I did wrong?
I opened your file. The problem is: your report layout is wrong.
Your Sum() formula is in the page footer - that cannot work, because it is pretty much random how many records will be on one page.
Move it into the report footer, and it works without changes.
But it's still wrong, because you have multiple customers in your query. So you need to add a grouping by customer id. Then move everything from the page header to the group header, and the Sum() to the group footer.
For anybody else stuck on this. The following does what I needed!
When creating the grouping, ensure that you select "with a footer section!"
There is possibly a better way to achieve the end goal, but this works!

How to list values from MySQL table in VB.Net

I would have posted some code, however I completely have no idea where to start!
So I want my employees to use my VB application to request holiday (that bit is done). But now I want them to see all the holidays they have requested in a list.
They each have their own account and their username is present on the holiday table in the database.
It must be able to show all holidays they have booked and not just one, preference is in a list form. I'd also like to exclude 1 column from showing.
Is this possible?
I really appreciate your help in advance.

Access 2010 update date field based on another field

I'm relatively new to Access and VBA but I have managed to get some basic VBA tricks working in both Access and Excel. Now I've got a challenge that I can't seem to crack. I'm building a database to track maintenance of a small trucking fleet. I've got most of the tables and forms I need to do the basic tracking and management of equipment and maintenance in place.
One of the things we're tracking is called PM's which stands for preventative maintenance (lube jobs and oil changes). We do those on calendar intervals for trailers and mileage intervals for tractors. Right now, I'm trying to get the calendar tracked equipment working. I've a table called tblEquipmentMaster which is where all the specifics for each piece of equipment is kept (make, model, year, VIN, etc) and that table has a field called LastPMDate. All the maintenance records go in two other tables, tblMaintenance which records the unit number, vendor, invoice date and invoice amount and tblMaintenanceDetails which records the each line item of work that was performed on the unit (i.e. replaced water pump, replaced headlight etc).
The maintenance details table also contains a drop down list of standard maintenance codes to allow for easier searching of certain maintenance items later. One of those codes is PM. I also have several forms built to interact with these tables including a data entry form for adding new maintenance records.
What I'm trying to accomplish is to have the LastPMDate field for any unit number in tblEquipmentMaster automatically update to match the InvoiceDate field in tblMaintenance anytime an invoice is entered for that unit number which has a line item containing the code PM.
I've tried building an update query to do this but in addition to changing the LastPMDate field like I want it to, it also ends up changing the invoice dates for all previous PM invoices to the date of the last invoice which contained a PM. Not good.
So my question is, would an update query be the best way to do this or would I be better off with some sort of VBA solution? I have an add record button on my maintenance invoice data entry form which users use as a save record/clear form button when all the info for an invoice has been entered. I'm thinking some VBA code tied to the on_click of that button which would look at the invoice you just added, determine if it contains the PM maintenance code, then update LastPMDate field for that unit number with invoice date from that invoice would be a good way to do it but I honestly have no idea what functions or methods I'd need to get that to work.
Any insights or suggestions appreciated.
It's very hard to follow the flow of what you are describing, even if I have experience of PM and AM (Autonomous maintenance).
What is lacking is the relations between the three tables.
Nevertheless I prefer VBA solutions (maybe because I started programming when everything had to be written...). With VBA you can finely control your workflow.
If I understood well the 1st table is tblMaintenance in which you have the Invoice data.
Then you should have to scan the tblMaintenanceDetails to find the list of PMs and filter the tblEquipmentMaster with current PM value to update the LastPMDate with the date of the 1st table.
Did I succeed in providing you an idea to solve your problem?
Let me know.

Table Design for my Database

I am in the process of designing a very simple system for keeping track of a shifts worked by the sales team. Although i'm still designing and not done yet, I later realized I left out one important detail that I'll get into.
Some quick background first:
Each shift consists of how long the shift was (hours worked), whether it was the morning, afternoon, or night shift (or some combination), how much in sales were made for that shift, and how many tips the person made that day. I also keep track of things like whether it was cash or credit tips you received for doing your job well.
So one extra thing that happens is the sales team gets paid by the hour. For reports and running totals I am currently just calculating your income for that shift as pay rate (from job Position table) multiplied by the hours you worked, but I forgot the fact they could get raises! This means that if you get a raise, your income would magically increase (historically speaking)! I might've been making $10 an hour last year, and now $15 an hour this year - So the reports would be wrong.
My initial thought was to simply add a new column in my 'shift' table called HourlyRate, and that would be whatever the current hourly rate was at that moment in time. $10, $15, etc. Then I can just use this rate when i'm performing calculations
Do you all think this is an acceptable solution? Would it be weird to have a few hundred rows of sales all with the exact same hourly rate column for the same sales worker?
Thanks so much for your help!

MS Access Report Formatting

I have an access report that has two grouping levels, for the most part it works great, but occasionally the detail is too long and the final total prints on a page all by itself. The client would like to move the last detail record to the next page when that happens so the total is not by itself. I know in other reporting tools this is relatively simple... but so far I have not been able to figure out how to do it in Access...
Does anyone have any ideas or has anyone done this before?
Group by Project Name
Group by Project Phase - this footer has the total
Group on Change Order - this footer has a subtotal for each group
The subtotal seems to always stay with the current record, but I cannot figure out how to keep the project phase with the last 'change order' group....
Any help is appreciated!
Look at the KEEP TOGETHER property of your group footer. This may or may not do the job, but it's the feature designed to fix this issue. You also may want to check the REPEAT property, which can help make a report more readable.
In report design view, open "Sorting and Grouping" (from menu or toolbar). Select the group level you want to control, which is probably the bottom-most. Set "Keep Together" to "Whole Group", or possibly "With First Detail."