Results 1 to 11 of 11
  1. #1
    GAccess is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    38

    Adding subtypes and comparing value to main type

    New to this portion of access , never really had to code/program behind the scenes for calculations. Primarily did user face calculations in access and excel and as well as reports /queries in access.

    I have Three Tables

    Table A
    Department "Name"
    Department "Budget-Value"



    Table B
    Section "Name"
    Section "Budget - Value"

    -section represents what the department is paying for : such as Electricity, Misc., Extracurriculars, Entertainment, Supplies, Research etc. Each section has a budget.

    Table C
    Invoice "Number"
    Invoice "Amount"
    Invoice "Paid"

    - Invoice represents the receipt given for spending - the amount requested sometimes differs from the amount paid

    I wanted to know if SQL or VBA can help with my dilemma. I want to alert the user when spending has hit a limit so that they can slow down on/stop spending.

    So the invoices paid cannot exceed its respective section, and the section budgets entered cannot exceed the entire department's budget.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    It shouldn't be difficult, but wouldn't you need a field(s) in Table C to identify the section/department?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    GAccess is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    38
    Yes, apologies .. I do have that in table c@ pbaldy.

    I honestly dont know how to approach this.

    Would I need Dlookups? please help!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    I don't think so. Your problem isn't much different than this:

    https://www.accessforums.net/showthr...-Hand-Quantity

    I'd have a query to sum up the transactions by section, and then a query that joins the section table to that query so it can compare the budget to what's been spent.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    GAccess is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    38
    I was looking to get real time calculations to stop the user from entering any more financial expenditures. The queries are not too hard to do.. but let me go ahead and check your link first.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    "real time" is simply a matter of checking the query at the appropriate times. From the sound of it, in the before update event of the form so you can stop the entry if you want.

    http://www.baldyweb.com/BeforeUpdate.htm

    Except you'd be checking your query.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    GAccess is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    38
    Thanks pbaldy for being willing to help, but the link is not quite what the goal is.

    I would like the user to know there is a problem when budget values for each respective group are being exceeded.

    Sum InvoicesA = Sum Section BudgetA = Sum DepartmentA
    Sum InvoicesA = Sum Section BudgetB = Sum DepartmentA
    Sum InvoicesA = Sum Section BudgetC = Sum DepartmentA

    Sum InvoicesB = Sum Section BudgetA = Sum DepartmentA
    Sum InvoicesC = Sum Section BudgetA = Sum DepartmentA

    and so on

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    It would help if you posted a sample of your data, with the desired result.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    GAccess is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    38
    Department Section Section Budget Invoice # Invoice Amount Paid on Invoice
    Customer Service 4122 3000 4AR-TY 2000 2000
    Customer Service 4122 3000 41EPO 1000 900
    IT 33333 4000 98234-R 3000 3000
    Lab 33333 4000 4324 3000 2500
    Tax 33333 4000 R2342 4000 4000
    Legal 333457 6000 J2352 5000 5000
    Legal 987456 3000 QP-0909 1000 500
    Engineering 287333 5000 404054 3000 3000

  10. #10
    GAccess is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    38
    let's say Customer Service has a Budget of 7000.
    Section code 4122 has a budget of 3000.

    When customer service receives an invoice "4AR-TY" for the amount of 2000, they pay 2000 on the invoice.

    So now customer service has 1,000 left in their budget for section 4122.

    Customer service goes out buys again. They receive an invoice " 41EPO" in the amount of 1000, they only had to pay 900.

    SO now customer service will have $100 left on Section code 4122 to spend.. If they try to enter an invoice for more than 100, I want the system to lock them out from doing so.

    Though different departments share the same section code... the section codes are used per department, exclusively.

    I just want this calculation stuff somewhere in the background as a check and balance. Do you still think you can help?

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    I was hoping for an actual database to play with. That doesn't look like the structure you described earlier. Since I don't know the structure, I'll simply say that you can add up what's been spent with a totals query or DSum() and compare that to what was budgeted.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 03-14-2012, 10:08 AM
  2. Comparing Date
    By J Guggs in forum Queries
    Replies: 1
    Last Post: 01-15-2012, 12:41 PM
  3. Replies: 2
    Last Post: 12-07-2011, 02:51 AM
  4. Comparing tables
    By YoungWolf in forum Database Design
    Replies: 7
    Last Post: 01-10-2011, 11:32 AM
  5. Replies: 2
    Last Post: 03-18-2010, 08:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums