What event?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MichaelSL
    New Member
    • Apr 2008
    • 4

    What event?

    I have a form with a text field. When I exit that field I have a VBA which processes the entered data. The processing needs to be different if the user is leaving the record or moving to a different field. Since the textbox_Exit seems to run before any other event handler, is there a way to know what the user requested (what was clicked or pressed)?
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    "textbox_Ex it seems to run before any other event handler"

    Actually, this is not true! When leaving a textbox, in order to move to another control within the same record, the events fire in this order:

    Textbox_BeforeU pdate
    Textbox_AfterUp date
    Textbox_Exit

    If the user, with the cursor still in the textbox, clicks on a button to move to another record, or clicks on a button to close the form, the order is as follows

    Textbox_BeforeU pdate
    Textbox_AfterUp date
    Form_BeforeUpda te
    Textbox_Exit

    You say if the user simply moves to another field, you want to do CodeA, but if they move to another record, you want to do CodeB, based on the content of the textbox. The important question here, I think, is what exactly is CodeA and CodeB doing, and if the user elects to move to another record, does CodeA still need to be run?

    We really need to know more about your intentions in order to help you.

    Welcome to bytes!

    Linq ;0)>

    Comment

    • MichaelSL
      New Member
      • Apr 2008
      • 4

      #3
      You asked for more, so here goes:

      I have "Test Cases" (unbound) with Steps (bound) and SubSteps (bound) (all integers) with each SubStep being a record. Here are the form conditions:

      *************** *********
      Move to Next Record/New Record
      1) If there already is a TestCase, keep it and set the focus to the TestCase field.
      2) If there is not already a TestCase, use the TestCase value from the record that was just left, set Step and SubStep to 999999

      *************** *********
      Move from the TestCase field to a different field
      If Step = 999999
      ...set Step to max (TestCase's Step) + 1
      ...set SubStep to 1
      ...Step.SetFocu s
      Else If SubStep = 999999
      ...set SubStep to max (TestCase's Step's SubStep) + 1
      ...SubStep.SetF ocus
      Else
      ...OtherField.S etFocus
      End If

      *************** *********
      While TestCase has focus, leave record
      If Record exists in database
      ...update if required (currently performed automatically)
      Else (this would become a new record)
      ...If Step <> 999999
      ......If all required fields have been filled out
      .........Update the database (currently performed automatically)
      ......Else
      .........Displa y msgbox
      .........Do not move from record
      ......End If

      *************** *************** *************** **
      *************** *************** *************** **
      THIS IS THE PART I NEED HELP ON. TestCase_Exit COULD HANDLE THIS IF IT NEW WHERE IT WAS GOING!
      ...Else (Step = 999999)
      ......Perform an UNDO
      ......Perform record move.
      ...End If
      End If

      I have tried using BeforeUpdate. This does not work because TestCase is a Unbounded field so the Form_BeforeUpda te is not executed.

      Comment

      Working...