Set Focus on a control within a continuous subform

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JAYR
    New Member
    • Mar 2007
    • 2

    Set Focus on a control within a continuous subform

    I have a continuous form as a sub-form on a main form. After updating a control on the sub form I perform checks on what has been entered. If it is incorrect i need to set focus back to that control for re-entry. My question is how do I set the focus back to that control - a simple Me.[control].SetFocus does not work. I would appreciate any help. Thanks
    PS I am trying to set the focus from within the subform
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by JAYR
    I have a continuous form as a sub-form on a main form. After updating a control on the sub form I perform checks on what has been entered. If it is incorrect i need to set focus back to that control for re-entry. My question is how do I set the focus back to that control - a simple Me.[control].SetFocus does not work. I would appreciate any help. Thanks
    PS I am trying to set the focus from within the subform
    Perform you checks in the BeforeUpdate() Event of the Control within the Sub-Form. If the entry does not pass your checks, notify the User, then set the Cancel Parameter to True. The Focus will never leave the Control as long as the checks are not passed as in:
    Code:
    'If the Quantity entered is > 500, do not leave or update the Control.
    If Me![Qty] > 500 Then
      MsgBox "Invalid Entry - Quantity cannot be > 500", vbExclamation, "Invalid Entry"
      Cancel = True
    End If

    Comment

    • JAYR
      New Member
      • Mar 2007
      • 2

      #3
      That worked thanks heaps

      Comment

      Working...