Results 1 to 4 of 4
  1. #1
    Scorpio11 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jun 2010
    Location
    Cape Town, ZAR
    Posts
    36

    VBA Across Multiple Records (Access 2010)

    Hi

    I am very new to VB Coding in access and am testing a simple things.

    I have drafted a simple VBA code in a form button that takes the result calculated in a query and pastes the result into a table.

    I have attached my test database to illistrate

    In my attached database, i have a list of 5 records, i am wanting to push the calculation button have all the records updated with the result that is calculated in the query in 1 go.



    As it stands right now i have to do it one at a time per record, which is not preferable when there are potentially hundreds or thousands of lines. I am wanting to do this because i want to reduce my reliance on calculated cells in forms and reports where i have to draft long formulae across 3 separate queries to get the result i am looking for.

    Any help would be appreciated.
    Attached Files Attached Files

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    You want to update Result3 with the value in Test7 in each row?
    I'm not sure I understand why you need to do this because your query 'Tquery1' is already doing the calculation for you and displaying the result in the 'Test7' field. It seems like you're doing the same thing twice - once in the query - and then once in the Calc button . . .

    It IS possible to automate the Calc button but perhaps you could explain with a little more detail?

  3. #3
    Scorpio11 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2010
    Location
    Cape Town, ZAR
    Posts
    36
    Hi There

    Yes that is correct.

    I agree with you, in my example, it is not needed to do this as the result is simple.

    The reason why i want to do this is that I have queries containing 3 nested formulas and to get to my FINAL result, i need 3 queries to get there. needless to say, it is a little slow when it comes to running reports and such
    I want to do this so i can let access take it time every now and then do what it needs to and calculate the result and then dump the result into a table and generate my graphs and forms and reports based on the table information and not the query. The intention is to speed up my database by cutting the constant recalculating time.

  4. #4
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    If you look at this thread:
    https://www.accessforums.net/showthr...ted-table-rows
    you will see a code outline I put in there that allows you to read rows of data from a query and then write some or all of the data from the query into another table.

    The code reads the data from the query one row at a time and before it goes to the next row, it writes the data retrieved from the current query row into a different table.

    If this is your first time using code, it will take a little time for you to see what is happening, but I think I have put enough explanation in comments so that you can follow the logic.

    Let me know if this helps.

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

Similar Threads

  1. Replies: 5
    Last Post: 03-01-2012, 01:11 PM
  2. Replies: 3
    Last Post: 01-17-2012, 01:04 PM
  3. How do I create multiple records in Access?
    By Astron2012 in forum Access
    Replies: 14
    Last Post: 01-09-2012, 10:41 AM
  4. Replies: 1
    Last Post: 01-05-2012, 02:34 PM
  5. Combining multiple Excel records into Access
    By Jadey78 in forum Import/Export Data
    Replies: 0
    Last Post: 05-04-2010, 07:51 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