Results 1 to 4 of 4
  1. #1
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Refresh calculated field (2K)

    Hi,
    I have a form that calculates a value when a date is entered.
    Basically an initial date is entered in ArrestDate (This is a field in TblMain), on this is then added 71 days which goes into TargetDate.

    I also have 3 other fields that do calculations to work out days remaining (DaysLeft), days over(DaysOver) and total days(TotalDays). The first two being based on whether the target date has passed, the last one based on how many days in total have passed from ArrestDate.

    They are all fields in TblMain from which the form is based.

    I would like DaysLeft, DaysOver, TotalDays all to requery whenever the date changes.

    I have TxtNow which contains the current date and is refreshed on FrmMain.

    I've tried:

    Me.DaysLeft.Requery
    Me.DaysOver.Requery
    Me.TotalDays.Requery

    on the form load event.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Refresh calculated field (2K)

    To update calculations, you should use Me.Recalc.

    But it not clear what you're doing. On the one hand, you write "... when a date is entered ...", on the other hand, you mention "TxtNow which contains the current date".
    And the On Load event of the form occurs only when it is opened, not when a text box is updated.

  3. #3
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Refresh calculated field (2K)

    I added Txtnow which updates daily so that I could check against this to see whether the target date had passed. I also use TxtNow for another function so this isn't a problem.

    However as these fields are calculated I need them to refresh everytime a record is opened. So basically it counts down to the target date. ArrestDate and TargetDate will never be refreshed, just DaysLeft, DaysOver & TotalDays.

    Do I literally use:

    Me.DaysLeft.Recalc ?

    Congratulations by the way on the phenomenal volume of posts you've done. Well done!!!!

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Refresh calculated field (2K)

    Recalc is a method of the form as a whole, so the command is

    Me.Recalc

    This will recalculate all calculated controls on the form.

    And thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •