Results 1 to 9 of 9
  1. #1
    5 Star Lounger
    Join Date
    Jul 2004
    Location
    Ohio
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Control tab-Index (2k)

    i have a form with 78 text boxes in a subform that each link to its own control source where data is entered. When the subform is opened, i want to go to the first empty text box. I am going through changing the tab indexes now, but im wondering how to actually cycle through in code. what im thinking is something like this:

    for x = 1 to 78
    if text_control_tab_index(x).text = "" then exit for
    subform1.text_control_tab_index(x).setfocus
    next x

    i know thats not how it works, but thats the basic idea of what im trying to do. is this possible to do?
    <img src=/w3timages/blueline.gif width=33% height=2>
    <big>John</big>

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

    Re: Control tab-Index (2k)

    Perhaps you should reconsider the entire design. Seventy-eight text boxes? <img src=/S/yikes.gif border=0 alt=yikes width=15 height=15>

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Control tab-Index (2k)

    You can use something like this to loop through the controls. The tab index and the control index aren't the same thing, so don't bother with them. Just examine each control until you come to an empty textbox

    Dim ctl As Control

    For Each ctl In Me.subform1.Section(0).Controls
    If TypeOf ctl Is TextBox Then
    If Len(ctl & "") = 0 Then
    ctl.SetFocus
    Exit For
    End If
    End If
    Next ctl

    Set ctl = Nothing
    Charlotte

  4. #4
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Control tab-Index (2k)

    Charlotte, of course, gave you the best way to cycle thru your controls. However, I want to add one little comment about an error in your original code. The .Text property of a control is not available unless that control has the focus. If you want to examine the contents of a control at any other time, you must use the .Value property (which is the default property, and therefore doesn't need to be directly specified).
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  5. #5
    5 Star Lounger
    Join Date
    Jul 2004
    Location
    Ohio
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Control tab-Index (2k)

    Hans I wouldn't know how else to allow them to input to 78 different input sources that all contain meaningful data... my only hope of helping people out with this was to setfocus in the correct control for them to make it easier to input data.

    charlotte/mark thanks for your advice i'm going to try that out and see how it goes.
    <img src=/w3timages/blueline.gif width=33% height=2>
    <big>John</big>

  6. #6
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Control tab-Index (2k)

    I'm sure Hans was wondering that with 78 data fields in a record (although it is not necessarily bad in and of itself), that perhaps you had a non-normalized database design.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

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

    Re: Control tab-Index (2k)

    <img src=/S/yep.gif border=0 alt=yep width=15 height=15>

  8. #8
    5 Star Lounger
    Join Date
    Jul 2004
    Location
    Ohio
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Control tab-Index (2k)

    maybe i am overlooking something then. i have 39 data elements, each w/ a start and end date: 78 total data elements. employees use all of these data elements for charts and reports for management. having this pinpoints where an item is in a process tree. people input every one of these dates, and dwell times are calculated from the data. does anyone have a better suggestion in organizing such data? or input methods? i understand its a lot of controls but i don't know how to better implement it design wise.

    side note: i didn't disregard hans' post, i just don't know how to deal with such large quantities of data. im still an access novice.
    <img src=/w3timages/blueline.gif width=33% height=2>
    <big>John</big>

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

    Re: Control tab-Index (2k)

    I would probably use a separate table, linked to the main table, with a record for each main record - data element combination.

    <table border=1><td align=right>MainID</td><td align=right>ElementID</td><td align=right>StartDate</td><td align=right>EndDate</td><td align=right>1</td><td align=right>1</td><td align=right>01/01/04</td><td align=right>03/01/04</td><td align=right>1</td><td align=right>2</td><td align=right>03/01/03</td><td align=right>04/15/04</td><td align=right>...</td><td align=right>...</td><td align=right>...</td><td align=right>...</td><td align=right>1</td><td align=right>39</td><td align=right>02/01/04</td><td align=right>05/15/04</td><td align=right>2</td><td align=right>1</td><td align=right>03/15/04</td><td align=right>06/01/04</td><td align=right>2</td><td align=right>2</td><td align=right>02/01/04</td><td align=right>07/01/04</td><td align=right>...</td><td align=right>...</td><td align=right>...</td><td align=right>...</td></table>
    The elements would be presented in a continuous subform of the main form.

Posting Permissions

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