DataBase - total Amt Due, Taxes, Shipping, Expense and Total Amt Due on Invoi

Asked By Dennis
18-Mar-10 09:43 PM
Introduction:

This is similar to a posting I have in the Database group.  I tried to post
to two usenet groups for this question, but that did not work.

The invoice will include one or more line items for labor, parts, and
expenses (mainly mileage, tolls, etc.) We do not maintain an inventory. We
purchase the parts as needed from which ever vendor has the best price at
that time. As a result, the parts table is a little different from your norm.

My goal is to have all three items (labor, parts, expense) for a given Work
Order / Invoice appear on a single invoice in some a reasonable order.
Ideally, I would have ???associated??? items appear together. For example, if I
have replace a power supply and a disk drive, I would like to have the labor,
part cost, and any expenses for the power supply appear together and the have
the labor, part, and any expense for the disk driver appear together and then
have a total.


My Question:
My guess is I will not be able to do what I want, but I will be able to
group them using sub-report.  Even though it is not ideal, I could group my
invoice by labor, parts, and expense using sub-reports.

I will use the Work Order table for the main form and three sub-reports.
The first sub-report will use the Work Order Detail for the source.  The
second sub-report will use the Parts Detail for the source.  And the third
sub-report will use the Expense Detail as its source.

My question is how do I sub-total the different amount fields for each
sub-report and then for the final total?

The amounts for the Labor section are Time, Labor Rate, Amt Due (time *
labor rate).  I want to sub-total and total Time and Amt Due.

The amounts for the Parts sections are Quantity, Price, Extended Price,
Taxes, Total Amt Due.  I would sub-total Extended Price, Taxes, and Amt Due.
Some how I need to show total shipping charges also.

The amounts for the expense section are Expense Amt, Mileage, Mileage Rate,
and Total Expense Amt.  I would sub-total just the Total Expense Amt,
Mileage, and Expense Amount.

The bottom of the invoice would have the following totals:


Total Labor Amt Due = (total from Labor section)
Total Parts Due        = (total from Parts Extended Price)
Total Parts Taxes      = (total from Parts Taxes)
Total Shipping          = (total from Parts Shipping)
Total Expenses         = (total from Expense Amount)
Total Amt Due          = (total of the above)



Existing database structure:


Work Order / Invoice Table -
The work order is the created once a customer wants something done.

Key Work Order # - automatic number
Data Customer Number ??? FK to Customer Table
Employee ??? FK to Employee Table
Call Date ??? date field
Resolution Date ??? date field
Original Issue - text
Resolution ??? text
Note ??? note field


Work Order Det Table -
There is one record for each time entry.
I???m also using this info to generate the Employee???s Time Sheet Report.
I also use this information as my notes of what was done on each job
for each customer.

Key WO Seq No ??? auto number
Data Work Order number - FK to Work Order Table
Work Data ??? Date ??? Work date
Hours ??? decimal ??? hours in quarter hour increments.
Issue ??? note field ??? what issue did the employee work on.
Resolution ??? note field ??? how the issue was resolved.

Expense Report Table:
Key ExpRptNo ??? Automatic number
Data Employee No ??? FK to Employee
Expense From Dt ??? date
Expense To Dt ??? dade
Comments - Notes


Exp Report Details

Key Expense Seq No ??? auto number
Data Work Order - FK to Work Order Table
Expense Date ??? Date
Expense Type ??? FK to Exp Type Table
Milage ??? decimal
Rate ??? milage rate
EntryTypeID
(1)
WordOrderID
(1)
WorkOrderDetail
(1)
EmmployeeID
(1)
EmployeeID
(1)
Database
(1)
ExpRptNo
(1)
PartID
(1)
  Allen Browne replied to Dennis
19-Mar-10 12:31 AM
One work order can contain multiple line items.
You have 3 kinds of line items: labor, parts, expenses.

If possible, it would be ideal if you could keep all the lines in the one
WorkOrderDetail table. The fields would include something like this:
ID                  AutoNumber (primary key)
WordOrderID  Which work order this row belongs to.
EntryTypeID     Indicates if this row is for labor, parts, or expense.
EmployeeID    used only if the line is for labor.
PartID             used only if the line is for parts
Quantity          number of parts  or hours. Defaults to 1.
EachEx            Currency: price each part or each hour, without tax
TaxRate          Rate of tax to add to this row.

Now you can design a main form (for work orders) with a tab control that has
3 pages on it, to enter the labor, parts, and expenses. Each tab has a
subform bound to a query that draws only the relevant records from the
WorkOrderDetail table. The subform for labor has an EmmployeeID combo, but
no PartID combo. To the user, your interface looks like the values go into 3
different places (since that is how they think about the data), but they
actually end up on the one table. (You may have a 4th tab for shipping:
depends if you need to treat the differently.)

The advantage is that you can easily query the amounts from this one table.
In a query, you will have some calculated fields, e.g.:
Tax: CCur(Nz(Round([Quantity] * [EachEx] * [TaxRate],2),0))

Now you have the flexibility: if you want to create reports with a subreport
for each entry type, you can. But if you just want to use a main report and
use the sortin'n'grouping box to sort into sections with subtotals, you can
do it that way too.

--
Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
  Dennis replied to Allen Browne
19-Mar-10 06:15 PM
Allen,

Ah, I see.  I should have made my WorkOrderDetail table more of transaction
table (for labor, parts, expense) than break out those three items into
different tables.

That is where I screwed up.  Thanks.  If I put all of the transactions in
one file, it make life so much easier.

Once again, thanks for you assitance.


Dennis
Create New Account
help
service. I added the DeptLOP along with the following code: = DSum("WeeksService", "Service Record Query", "[EmployeeID] = " & [EmployeeID] & " And [DepartmentName] = Current_Department_Name" & " And [DeptLOP] > = Current_Dept_LOP" & "") This did not do the trick. Can anyone please Thanks in advance. - - Judy Access Discussions CurrentDb.OpenRecordset (1) WeekServiceFieldName (1) DeptLOP (1) JobTitleName (1) EmployeeID (1) Database (1) DepartmentName (1) DbOpenDynaset (1) Judy - I assume you are populating an unbound for the given department: IF Current_Department_Name = "Reserves" Then Me.WeekServiceFieldName = DSum("WeeksService", "Service Record Query", "[EmployeeID] = " & [EmployeeID] & " And [DeptLOP] > = " & Current_Dept_LOP) ELSE Me.WeekServiceFieldName = DSum("WeeksService", "Service Record Query", "[EmployeeID] = " & [EmployeeID] & " And [DepartmentName] = '" & Current_Department_Name & "' And [DeptLOP] > = " & Current_Dept_LOP) END IF - - Daryl S Perhaps the following is what you want = DSum("WeeksService", "Service Record Query", "[EmployeeID] = " & [EmployeeID] & " And ([DepartmentName] = Current_Department_Name OR [DeptLOP]> = Current_Dept_LOP)") Although instead of [DeptLOP] > = Current_Dept_LOP I would think
Access Discussions Excel (1) CurrentDb.Execute (1) VBA (1) AppointmentID (1) CaregiverID (1) VEmployeeID (1) EmployeeID (1) Database (1) Contact me and give me your email address and I will send Then 'if user exits an editable cell then vEmployeeID = Val(flxgrd.TextMatrix(vRow, 17)) 'fetch EmployeeID for this cell vDate = txtWeekEnding - (6 - ((vCol - 1) \ 2)) 'calc date from Col number and than 24 hours, please enter number again.", vbCritical + vbOKOnly, Else If Nz(DLookup("ID", "tblTimeSheets", "EmployeeID = " & vEmployeeID & " AND WorkDate = #" & Format(vDate, "yyyy / m / d") & "#")) = 0 Then If flxgrd.TextMatrix(vRow, vCol vCol + 1) <> "" Then 'if current day is NOT blank then CurrentDb.Execute "INSERT INTO tblTimeSheets (EmployeeID, WorkDate, StartTime, EndTime) VALUES (" _ & vEmployeeID & ", " _ & "#" & Format(vDate, "H:nn ") & "#, " _ & vWork & ", " _ & vOvertime If Else CurrentDb.Execute "UPDATE tblTimeSheets SET " _ & "HoursWorked = " & vWork & ", " _ & "HoursOvertime = " & vOvertime & " " _ & "WHERE EmployeeID = " & vEmployeeID & " AND WorkDate = #" & Format(vDate, "yyyy / m / d") & "#" 'update tblTimeSheets table with amended data End and will not insert the new format into the cell: CurrentDb.Execute "INSERT INTO tblTimeSheets (EmployeeID, WorkDate, StartTime, EndTime) VALUES (" _ & vEmployeeID & ", " _ & "#" & Format(vDate, "H:nn ") & "#, " _ & vWork & ", " _ & vOvertime use to enter times into those fields. So the line :- CurrentDb.Execute "INSERT INTO tblTimeSheets (EmployeeID, WorkDate, StartTime, EndTime) VALUES (" _ & vEmployeeID & ", " _ & "#" & Format(vDate, "H:nn ") & "#, " _ & vWork & ", " _ & vOvertime & ")" should be something like (watch for word wrapping) :- CurrentDb.Execute "INSERT INTO tblTimeSheets (EmployeeID, WorkDate, StartTime, EndTime) VALUES (" _ & vEmployeeID & ", " _ & "#" & Format(vDate, "H:nn ") & "#, " _ & "#" & Format(vWork, "H
assigned to Mgr 1 Employee 1 reviewed by non assigned Mgr 2 Access Queries Discussions EmployeeID (1) ReviewerID (1) ManagerID (1) Report (1) TblEmployeeReview (1) TblEmployee (1) TblHierachy (1) TblReview (1 I am assuming that all review records are in a single table - - SELECT FName, LName, EmployeeID, tblEmployeeReview.Reviewer, [XX].Reviewer FROM (tblEmployee LEFT JOIN tblEmployeeReview ON tblEmployee.EmployeeID = tblEmployeeReview.EmployeeID) LEFT JOIN tblEmployeeReview AS [XX] ON tblEmployee.EmployeeID = [XX].EmployeeID WHERE tblEmployeeReview.Reviewer <> [XX].Reviewer; - - Build a little, test a little. This is a bit Thanks for your help and patience. Looks like this works: SELECT DISTINCT Review.ReviewID, Employee.EmployeeID, Employee.ManagerID, Reviewer.ManagerID AS ReviewerID FROM Employee AS Manager INNER JOIN (Employee INNER JOIN (Employee AS Reviewer INNER JOIN Review ON Reviewer.ManagerID = Review.Mgr) ON Employee. EmployeeID = Review.Emp) ON Manager.EmployeeID = Employee.ManagerID WHERE (((Reviewer.ManagerID)<> [Employee].[ManagerID])); If you open
tblAssets tblEmployees frmAssets tbleEmployees, among other things, has columns for User FirstName, User LastName, and EmployeeID. frmAssets primarily deals with tblAssets but pulls from other locations, including tblEmployees. frmAssets has field for EmployeeID, but not employees names. There are two requirements: 1) When displaying entries in frmAssets, I want to see the employees name corresponding to the EmployeeID stored for that asset record in tblAssets. 2) When entering new records in frmAssets, I the appropriate employees name from a drop-down list and have it store the corresponding EmployeeID value in tblAssets. Can I do this simply using a query or coding and tblEmployees because it already has both the EmployeeID and the names? Or would it be better to build this using a query that IDs to names? Or is there another way I am missing altogether? Access Queries Discussions EmployeeID (1) ColumnCount (1) BoundColum (1) FirstName (1) TbleEmployees (1) TblEmployees (1) FrmAssets (1) TblAssets (1 name instead of id Add a combo box to frmAssets, set up as follows: ControlSource: EmployeeID RowSource: SELECT EmployeeID, [User FirstName] & " " & [User LastName] FROM tblEmployees ORDER BY [User LastName], [User FirstName]; BoundColum: 1 ColumnCount
Holiday.datefrom, Holiday.dateto, Holiday.descr, Holiday.ho_hrs, Holiday.ho_mts, FROM employee, Holiday WHERE ( Holiday.employeeid = employee.recordid ) order by Holiday.employeeid, Holiday.datefrom Please help With thanks Pol Access Discussions LEFT JOIN (1) Inner (1) LEFT (1) Holiday.employeeid (1) Holiday.datefrom (1) Employee (1) Hi pol, What i would normally do is change the FROM statement to the following: FROM employee left join holiday on Holiday.employeeid = employee.recordid and obviously drop this from the WHERE statement Hope this helps. . . W - - The Holiday.dateto, Holiday.descr, Holiday.ho_hrs, Holiday.ho_mts, FROM employee LEFT JOIN Holiday ON (Holiday.employeeid = employee.recordid ) ORDER BY Holiday.employeeid, Holiday.datefrom OR you might try the following SELECT employee.company, employee.recordid, employee.employee Holiday.datefrom, Holiday.dateto, Holiday.descr, Holiday.ho_hrs, Holiday.ho_mts, FROM employee, Holiday WHERE Holiday.employeeid = employee.recordid OR employee.recordid is Not Null order by Holiday.employeeid, Holiday.datefrom John Spencer Access MVP 2002-2005, 2007-2010 The Hilltop Institute University of