Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    New Jersey, USA
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    set focus on subforms (97 sr2)

    I have a subform that must have data entered into a control. I am using the before update on the main form to trigger a check and a message if there is not data entered. This works fine. My problem is I want to set focus to the control on the subform as part of the error message. It is not working, is there a special way to do this? Special syntex?
    Thanks

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

    Re: set focus on subforms (97 sr2)

    Hi Cathy,

    This must be done in two steps:
    1) Set focus to the subform.
    2) Set focus to the control on the subform.

    For example:

    Me!sbfMySubform.SetFocus
    Me!sbfMySubform!ctlMyControl.SetFocus

    sbfMySubform must be the name of the subform as a control on the main form. This is not necessarily the same as the name of the subform in the database window. Open the main form in design view and click once on the subform, you will see its name as a control in the Properties window.

  3. #3
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    New Jersey, USA
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: set focus on subforms (97 sr2)

    I am getting run_time error 2110, Microsoft access can't move the focus to the control SBSecurityInfo.
    Here is my code it is really simple
    If Isnull(Me!SBSccurityInfo![cbodesc]) then
    Msgbox " You must enter an issuce source" THIS IS WORKING
    Me!SbSecurityInfo.setfocus 'HERE IS WHERE I AM GETTING THE ERROR
    Me!SbSecurityInfo![cbodesc].setfocus
    exit sub
    end if

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

    Re: set focus on subforms (97 sr2)

    Could you post a stripped down copy of your database? See <post#=401925>post 401925</post#> for instructions.

  5. #5
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    New Jersey, USA
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: set focus on subforms (97 sr2)

    Here is the zip. The problem occurs when you make a change to the form but do not enter anything in the issue source dropdown, then try to move to another record. I want this field to work like the other fields when the users does not enter data and tries to move on.

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

    Re: set focus on subforms (97 sr2)

    I don't see an attachment...
    Make sure that you specify the attachment just before you click "Post it". If you preview your post, the attachment box will be cleared.

Posting Permissions

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