Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618

    Expression in query calculating from Excell spreadsheet.


    Over more than 30 years business, I set up budget and cash flow projections on spreadsheets like in image 1 in Excel. I want our budget and projections to be part of our application. In our application there is one table that stores all transactions, one record after the other, with dates descriptions and amounts, and we are satisfied with the result. Image 2 shows a report. For the budget variance report to be correct, my challenge is to get the actual numbers into a field and the budget numbers next to it. I may manage to set up the budget looking like Image 1(in Access). I am not sure if I will be able to get an expression to set up the report. I must select "from" and "to" dates, when printing the Budget Variance report. Is it possible to set up an expression in a query that return number from an Excel spreadsheet?
    Click image for larger version. 

Name:	210424BudgetA.png 
Views:	38 
Size:	37.4 KB 
ID:	45081Click image for larger version. 

Name:	210424BudgetC.png 
Views:	37 
Size:	148.0 KB 
ID:	45083
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Surely Image 1 is not the raw data you want to filter? That data does not even show date values.

    What do you mean by "return number from an Excel spreadsheet"? If you have data in Access, why would Excel be involved?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    Hi, thank you. Assume that I will put in date values in the field headings on the Excel sheet. The result I want is calling up a report that compares actual numbers with budget numbers. As example "Electricity" on the spreadsheet calculate to 4000 or the first 4 months. Access stores transactions(records) with dates, descriptions and records one after the other, and we manage to set up expressions as we want it. If we posted the budget transactions in a similar way we do the actual ones it will work. I set up a table "Budget Scenarios" because if one scenario changes it adjust the whole budget. If budget transactions are posted like actual ones, I fall short of insight how to connect it to "Budget scenarios" in a way that the budget get adjusted. If I do the budget on a spreadsheet I have insight how to connect it to "Budget scenarios".
    Questions
    a. Can an expression in a query return amounts from an excel spreadsheet?
    b. Assuming the fieldname in Access can not be a date, it can not be used to calculate numbers for a certain period?

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    You can link an Excel file to your Access app and you will be able to use it in queries. But you should really try to eliminate the need for it by doing the budgeting in Access (you can present it like your Excel by using a cross-tab query).

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    a. Yes, Access can link to simple Excel sheets and work with them like tables - as sources for queries with calculations

    b. Cannot filter data presented in image by date range

    When building a relational database, forget everything you know about Excel. Start from scratch. Learn relational database principles, Access functionality, SQL, programming concepts, VBA language.

    Store data in normalized structure and manipulate with queries and code to get desired output.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    My wish for our app as far as budget concern must include:
    Firstly: Variable budget for testing.
    1. To be part of our app without importing or linking to spread sheets(excel).
    2. A variable budget(resulting query), not editable system linked to Scenarios(separate Scenario table and query, editable).
    3. There may be many more than 50 items that influence the budget, that will be found in the Scenario table. Quantities, Percentages, Amounts, Dates, Maximums, Minimums.
    4. The budget must be able to project for at least 60 months, and return a report for any single month or multiple months required.
    5. This budget is for testing, and not used for report purpose.

    Secondly: Actual Fixed budget, editable to be used for reports, including to compare with actual figures.
    1. If the budget above was tested and approved it must append to this different table. No Excel.
    2. Fields must be editable, not connected to scenarios. Every form in our app has an enable button and a password needed to edit existing information.
    3. Cross-Tab queries will help to return reports as in the attached excel spreadsheet, reports are not my current challenge.
    4. This table will store a very high quantity of records if the business use it for say 30 years.

    Will write a separate thread trying to clarify my challenge. Hoping or strategical advice which I fall short on.

  7. #7
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    Challenges
    My assumptions or insight that may be wrong or falling short.
    1. If you look at the attached excel spreadsheet with the supporting sheets, that works well for me.
    2. I assume that in both cases of my previous thread, I will need to capture one record for every month, for every budget subject, including quantities, percentages, amounts.
    3. The way I set up my query for the Variable budget, my experience is the expressions are far too many for one query.
    4. I do put in effort to obtain tutorials to learn more, but I think I fall short on strategy here.
    Attached Files Attached Files

  8. #8
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    Its been more than 5 years since we started to build and use our app. I only learnt today how to link to an excel sheet, simple. I need to learn how to do expressions in other queries returning numbers from the linked sheet. In my query "BudgetVariance" there are two fields "From Month" and "To Month". If I select Mar18 to Jun18 for the report, bank charges should return 8400. I need help with the expression or VBA.
    Click image for larger version. 

Name:	Excel2.jpg 
Views:	21 
Size:	268.6 KB 
ID:	45092

  9. #9
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Your problem will be that you have dynamic field names, due to the un-normalised structure.

    If your data was vertically stored e.g.

    BudgetSubject, Date, Amount


    It would be so much simpler
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  10. #10
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Please have a look at the attached sample for a custom VBA function. You can also use a union query to normalize your budget table putting them in a format similar to what Minty showed you above (see example in sample).

    Cheers,
    Vlad
    Attached Files Attached Files
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  11. #11
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    It seems that because the many expressions in a query are too much for Access, we will not be able to set up the Budget like I want to, stated in note #6 above. In excel I transposed the info(swapped the columns and rows around), that works. On the form a from date and to date can be selected, which means VBA must recalculate the result. The dates are in text fields on the form, not in a table or query. Let us say there are 50 budget items to be recalculated. Currently Access recalculate one record at a time as I open them on the form. I need the whole query to recalculate when a different date is selected. I have used refresh, it doesn't recalculate the whole query.

  12. #12
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    You need to use Me.Requery in the AfterUpdate event of both Start and End Date textboxes.
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  13. #13
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    Yes I have tried that, but the expressions that need to be recalculated are in VBA on the form. They don't recalculate, they would have if the expressions were in the query. Is it also your experience that expressions in VBA take less time to calculate than expressions in queries? Even though I am busy testing a different strategy, I will still want to learn the answer to this thread.

  14. #14
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Can you please show the form in design view? I assume you mean you used the custom function I've sent you in the control source of a textbox, is that right? Expressions using built in functions should be faster then the ones using custom VBA functions if that is what your asking.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  15. #15
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    I am not sure why the total in your query add to 8000, shouldn't it be 8400? My 23y.o. son had 3 years training in college, he works far away now. I trained myself during the past 5 years, having to run a business as well. Our development is doing a good job for us, but this budget section I fall short on strategy. Even though I used quite a few Modules, and no real training on VBA, I understand most of the time, the help is worth a lot. I will test what you suggest.

    In excel I transposed the information like on the image. It took a few hours, since I copied cell by cell. That is not what I really want (see quote #6) because if a budget item is to be added, it is quite a bit of work. On the image you will see cumulative numbers. When I select dates on the form let us say month 4 to month 12 the expressions would lookup the amount in month 12 less the amount in month 3. But I am not too happy with that either, will do it differently.
    Click image for larger version. 

Name:	210507BudgetD.png 
Views:	11 
Size:	160.3 KB 
ID:	45174
    Example of an expression in VBA. Me!AdminFee = IIf(Me.T005 = 1 And Me!EntityName103 = "AdminFees", DSum("AdminFees", "Excel03", "MnthInBus=" & Me.T009), IIf(Me!EntityName103 = "AdminFees", DSum("AdminFees", "Excel03", "MnthInBus=" & Me.T009) - DSum("AdminFees", "Excel03", "MnthInBus=" & Me.T006), 0))Click image for larger version. 

Name:	210507BudgetE.png 
Views:	11 
Size:	111.4 KB 
ID:	45175

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 03-19-2019, 08:35 AM
  2. Replies: 5
    Last Post: 12-03-2014, 11:34 AM
  3. Replies: 11
    Last Post: 03-31-2014, 03:15 AM
  4. Replies: 9
    Last Post: 01-31-2013, 12:55 PM
  5. import an excell spreadsheet in an access database
    By lmichaud in forum Import/Export Data
    Replies: 0
    Last Post: 11-03-2006, 08:29 AM

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