Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2002
    Location
    NYC
    Posts
    3

    Unanswered: Event trigger for a "group" of controls on Access form

    Hi All,

    Got an Access Form Control question for ya:

    I would like to perform some action when the focus is lost from a "group" of controls. That is, I have a set of similar controls after which the user leaves and goes on to another control on the form, some code needs to run.

    Specifically, I have a set of Latitude/Longitude fields that need to be updated (decimal converted to DMS or vice versa) when the user leaves this suite of controls. Any ideas?

    Thanks,
    Tony

  2. #2
    Join Date
    Oct 2001
    Location
    Bay Area, CA
    Posts
    117
    Create a function

    Function RunMyEvent()
    'Function code goes here
    End Function

    Then refer to this function from the exit events of each of the controls in your group:

    Private Sub SampleCode_Exit(Cancel As Integer)
    RunMyEvent
    End Sub

  3. #3
    Join Date
    Mar 2002
    Location
    NYC
    Posts
    3
    Torgue: thanks for the tip. The trick is that I need to detect that the focus is not on any of the other controls in that "group" before the update is run. Should I use .ActiveControl to check each control?

    Tony

  4. #4
    Join Date
    Sep 2001
    Location
    Chicago, Illinois, USA
    Posts
    601
    I know this is kind-of "kludgy," but . . .

    . . . since the Exit event is the first event fired on the "previous" control before the focus moves to the "new" control, you could set the value of a hidden control to True, on the Exit event of each control in your group of fields. All other fields could, on their Exit event, set that hidden field to False. Then, on those other fields, on the Got Focus event, you can test that hidden field and it would tell you whether the previous field was a "group" field, or not.

    There's got to be another way so if anyone else has the time to think about this one, please post a better solution.

  5. #5
    Join Date
    Oct 2001
    Location
    Bay Area, CA
    Posts
    117
    Yes, what PP describes can also be done with a flag, a public variable that knows which 'group' you are in.

    If you want to steer away from the group, use the flag or move to a dummy control.

  6. #6
    Join Date
    Mar 2002
    Location
    NYC
    Posts
    3
    Thanks for the advice, folks. I'll give it a try!

    Tony

Posting Permissions

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