Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Sydney, New South Wales, Australia
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Subform on a tab control (2K-SR1)

    How do I make the cursor jump from a field on page one of a tab control to a field which is in a subform on page two of the same tab control?

    I've created the code on the OnExit property of the field on page one and tried DoCmd.GotoControl and also SetFocus and combinations of both.
    I understand that the sequence is something like, go to the required page, go to the subform, then go to the field but I can't get it to work.

    Can someone help, please?

    Thanks
    Nick

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

    Re: Subform on a tab control (2K-SR1)

    You need to set focus to the subform first, then to the control in the subform. There is no need to set focus to the appropriate tab; that will be done automatically.

    So say that the name of the subform control is sbfMySub and the name of the control (text box, ...) bound to the field is ctlMyCtl.

    Then you'd use

    sbfMySub.SetFocus
    sbfMySub!ctlMyCtl.SetFocus

  3. #3
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Sydney, New South Wales, Australia
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subform on a tab control (2K-SR1)

    Thanks for the prompt reply.

    I tried it but it didn't work. An error msg was displayed: Run-time error '2110'. Can't move the focus to the control sbfMySub.SetFocus.

    Nick

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

    Re: Subform on a tab control (2K-SR1)

    Open your form in design view.
    Activate the tab containing the subform.
    Select the subform by clicking on it once.
    Note the name of the subform control - it's in the combo box in the formatting toolbar and in the title of the Properties window, and of course in the Name property.

    In your code, you must replace sbfMySub by the name you just noted.

    You must also replace ctlMyCtl by the name of the control on your subform you want to set focus to.

  5. #5
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Sydney, New South Wales, Australia
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subform on a tab control (2K-SR1)

    Sorry about my last reply. I did actually use the correct names for the subform and the control on it. As soon as I read your response, I realised my ambiguity.

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

    Re: Subform on a tab control (2K-SR1)

    I have attached a zipped Access 97 database that demonstrates two ways of setting focus to a control on a subform.

    I hope it works when you unzip iit and convert it to A2K.
    Attached Files Attached Files

  7. #7
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Sydney, New South Wales, Australia
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subform on a tab control (2K-SR1)

    Thank you.

    Yes, your attachment worked perfectly.

    This is all very strange because I used your method two originally, and method one obviously works. So this leads me to suspect there is some kind of corruption within the form itself.

    Maybe, I should recreate the form.

    I've found on occasions like this, it's best to create a blank db and import all objects from the old db. However this time, I won't import the troublesome form, I'll recreate it.

    Thanks for your help and patience.

    I'll do this in the next day or two and keep you informed. Watch this space ...

    Nick

Posting Permissions

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