Getting data to refresh automatically

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bhujanga
    New Member
    • Aug 2006
    • 44

    Getting data to refresh automatically

    I have a form for entering various contract information. On that form there are some fields that contain the total budget for the contract, which is a single field in the 'Contracts' table, which is the data source for the table. There is also a field for total invoices and the remaining unspent amount in the contract. The total invoices sum up the amounts from the "Invoices" table for all invoices with that Contract No.
    I have a button on the 'Contract' form that opens an 'Invoice' form. The 'Invoice' form shows all existing invoices for the contract and allows you to enter new ones. Then you close the form and you're back to the contract form.
    All of this is working fine.
    Here's the thing though: When it goes back to the contract form the total invoice amount isn't updated to reflect the changes that were made. If I manually refresh the record it all comes in, but I don't want people to have to know to do that. I haven't been able to find an event where I can put the Refresh command that makes it happen automatically. Can anyone tell me what will do it?
    Thanks you.
  • Khriskin
    New Member
    • Feb 2008
    • 20

    #2
    Assuming that you have [frmContracts] open at the same time as [frmInvoices], then you can trigger a refresh of the first form in the close function from the second form:

    [Forms]![frmContracts].Requery

    You can also requery the Total amount, assuming it feeds from a query:

    [Forms]![frmContracts]![varTotalAmount].Requery

    Hope that helps!

    EDIT: Sorry, forgot to include you can put this in the Form_Close() event. (doh)

    Comment

    • Bhujanga
      New Member
      • Aug 2006
      • 44

      #3
      Thanks. I used your first suggestion. Much more straightforward than what I was trying to do. (I was trying to get DoCmd.RunComman d AcCmdRefresh to do it, and couldn't figure out how to point it to the Contract table from Event code from the other form.)

      Comment

      Working...