Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    3 Star Lounger
    Join Date
    May 2003
    Location
    Sacramento, California, USA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Subforms tab order (2k)

    How can I change the order in which I tab into my subforms? I've got two subforms on a main form, and I need to tab into the classes subform before the billing subform and the way it's currently set up it goes right to the billing subform. Would this be an "on exit" event of the main form?

    Thanks for the advice <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

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

    Re: Subforms tab order (2k)

    A subform as a control on the main form has a TabOrder property, just like other controls. With the main form open in design view, select View | Tab Order... you can drag the Classes subform to be higher in the tab order than the Billing subform.

  3. #3
    3 Star Lounger
    Join Date
    May 2003
    Location
    Sacramento, California, USA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subforms tab order (2k)

    Ah! Perfect--Once again Hans you've saved the day!

    PS Do you ever sleep??? <img src=/S/snore.gif border=0 alt=snore width=32 height=15>

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

    Re: Subforms tab order (2k)

    Sleep? Now lemme think...

  5. #5
    3 Star Lounger
    Join Date
    May 2003
    Location
    Sacramento, California, USA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subforms tab order (2k)

    <img src=/S/yawn.gif border=0 alt=yawn width=15 height=15> Wake up Hans, I have another question. My first subform (classes) should be limited to only a maximum of three records-Each student can take a max of three classes. When I get to the third class and hit tab again it of course gives me a blank record to fill in. First, how do I limit it to 3 records? Next, outside of using control tab, how can I then (after entering 3rd class) tab directly into the first field of the billing subform???
    Macro perhaps?

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

    Re: Subforms tab order (2k)

    To prevent more than three records to be inserted, you could use the following code in the OnCurrent event of the Classes subform:

    Private Sub Form_Current()
    Me.AllowAdditions = (Me.Recordset.RecordCount < 3)
    End Sub

    To tab from the last control of the subform back to the main form when 3 classes have been entered, you can use code in the OnExit event of the last control (in the tab order) of the subform:

    Private Sub TheLastControl_Exit(Cancel As Integer)
    If Me.CurrentRecord >= 3 Then
    Me.Parent!SomeControl.SetFocus
    End If
    End Sub

    You must replace TheLastControl by the name of the last control in the tab order of the subform and SomeControl by the name of the control on the main form that should receive the focus.

  7. #7
    New Lounger
    Join Date
    May 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subforms tab order (2k)

    Private Sub TheLastControl_Exit(Cancel As Integer)
    The "Parent" portion of the below code is tricking me up--I need to tab out of the first subform (classes) into the second subform (billing). I tried replacing parent with child but that doesn't work. I don't know how to code, thus the question. What seems logical would be to insert the name of the subform there. Logical to this newbie at least <img src=/S/blush.gif border=0 alt=blush width=15 height=15> Please Help

    Greatly appreciated!

    If Me.CurrentRecord >= 3 Then
    Me.Parent!SomeControl.SetFocus
    End If
    End Sub

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

    Re: Subforms tab order (2k)

    You will need to replace Me.Parent!SomeControl.SetFocus by two statements: one to set focus to the Billing subform, and another one to set focus to a control within that subform. Try using this instead of the original statement:

    Me.Parent!sbfBilling.SetFocus
    Me.Parent.sbfBilling.Form!SomeControl.SetFocus

    where sbfBilling is the name of the Billing subform as a control on the main form and SomeControl is the name of the control in the Billing subform that should receive the focus.

  9. #9
    New Lounger
    Join Date
    May 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subforms tab order (2k)

    I'm halfway there! What a great help--
    On this portion of the code you gave me (where sbfBilling is the name of the Billing subform as a control on the main form and SomeControl is the name of the control in the Billing subform that should receive the focus.) the name of my billing subform is "Billing subform". Should I rename it sbfBilling? If I remember the spiel on naming conventions, I think I better. Also, the statement isn't accepting it as it is named currently.

    I'll try it and await your reply

    PS-glad to see I'm not the only one working on the weekend!

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

    Re: Subforms tab order (2k)

    Hello Gabi,

    If you are in a position to change the name of the subform to something without quotes, yes, that will make things easier in the long term. If you decide not to do that now, you must surround the names of objects with square brackets [ ] if they contain spaces or non-standard characters such as a hyphen. And for names not containing spaces, it doesn't hurt. So in this case:

    Me.Parent![Billing subform].SetFocus
    Me.Parent.[Billing subform].Form![SomeControl].SetFocus

  11. #11
    New Lounger
    Join Date
    May 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subforms tab order (2k)

    Hi Hans,

    I only included the quotes for clarity-I already changed the name of the subform to sbfBilling- So am I to assume that I do not need to add the brackets around that portion? My control BillingType is named exactly this way-no spaces or quotes. So my question just pertains to the brackets.
    Thanks

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

    Re: Subforms tab order (2k)

    If your subform or control names don't contain spaces, there is no compelling need to use square brackets. (But no harm is done if you do use them; you may have noticed that Access adds square brackets to expressions in queries whether they are necessary or not)

  13. #13
    3 Star Lounger
    Join Date
    May 2003
    Location
    Sacramento, California, USA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subforms tab order (2k)

    Hi,

    I worked on this at home this weekend and couldn't make it work, and I'm still not successful. After I enter the code for the OnExit event, a message pops up that says, "Object doesn't support this property or method". When I hit the debug button the highlighted line reads, "Me.Parent.[Billing subform].Form!BillingType.Set Focus". <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

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

    Re: Subforms tab order (2k)

    Hmm... try changing it to

    Me.Parent.[Billing subform].Form.BillingType.Set Focus

    with a <big>.</big> (point/period/dot) between Form and BillingType instead of a <big>!</big>
    Also, check very carefully that
    (1) Billing subform is the exact name of the second subform as a control on the main form (if you click once on this subform in the main form, this name is displayed in the caption of the Propperties window), and (2) BillingType is the exact name of the control on the Billing subform you want to set focus to, and (3) this control is enabled and visible.

  15. #15
    3 Star Lounger
    Join Date
    May 2003
    Location
    Sacramento, California, USA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subforms tab order (2k)

    Hans,

    It was the control name-It was "Combo box 19", changed it to BillingType, and now it works just peachy!
    Now I'm gonna try to do the code as you originally had me do it, to exit the final subform and go back to the first control on the main form. Question is, should I have it go a blank record, or back to the first control in the main form? Not so sure how best to proceed on this one...

    Thanks for all your help!

Page 1 of 2 12 LastLast

Posting Permissions

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