Results 1 to 3 of 3
  1. #1
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5

    Unanswered: Cannot get reset focus to a subforms control

    I have a form subform situation I have inherited. Basically quote and quote details(the subform)
    There is a refresh button on the parent form that calculates or re-calculates everything in the subfom (Qty, Price, markup)and takes the line item totals and populates the Parent form's "Totals" controls

    The previous developer used this "refresh" because they never wrote the code from the subform to do the calculations on the fly after they updated detail information below. Problem is that if a user does not "refresh" changes below are not calculated.

    The simple solution would be to call the on click event of that refresh button behind the after update event of the subform controls right? Wrong - the code runs (I have stepped through it ) but NO VALUES Change! Never have seen anything like that If I run the refresh click event from the parent - It updates data from the subform - if I call that button from the subform it does not. I then trie rewriting the click event into a function in the subform and adjusting the code to reference the controls appropriately - but I still cannot get data to reflect the changes!

    I then set the focus to the refresh button in the parent form afer the update of the controls in the subform and it worked!

    Problem is - for the lie of me after that code runs I cannot set the focus back to the next control in the tab order of the subform. I have used every methodI know of -
    1 Setting the focus to the subform first then the control
    2 referencing the control fully to receive the focus

    I cannot get the focus to come off of the Refresh button in the parent form

    needless to say this is a bigger show stopper for the user than to calculate their changes accurately (freaking users)

    Any help would be greatly appreciated
    Dale Houston, TX

  2. #2
    Join Date
    Jan 2009
    Location
    Kerala, India
    Posts
    180
    Try after adding a line of code: me.parent.refresh in the Sub-Form code, at the end of calculations.
    www.MsAccessTips.com (Learn MS-Access Tips & Tricks)
    Learn Advanced MS-Access Programming with sample VBA Code.

    All responses are based on Access 2003/2007

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    or possibly put some code in the sub forms after update event that forces a recalc in the parent form and or sub form.

    I'd remove the refresh button in the parent form though, thats just asking for trouble

    for belt and braces I'd probably want to make certain the values in the parent form matched the sum of the sub form just in case some comedian changes the sub form data at table level or through another form. prob do that in an on current event (probably in the parent form.... trigger say an event int he sub form.

    of course depending on what version of Access you are suing you may be abel to write a trigger at table level. think this can be done using macros in more recent versions of Access.

    Also I'd be tempted to wire up the original designers nadgers to mains electricity and make him / her / it respect the reasons why you don't store derived data... but then again I do have certain fundamentalist tendencies
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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