Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2009
    Posts
    9

    Unanswered: SetFocus/Tab Contrl issues

    Hello,

    I have a A questionaire that was so long it had to be split into three subforms (each subform is on a different tab, so there are a total of 3 tbas)

    I wanted to make filling out the questionaire seamless an easy for whoever has to enter in all the data, so on the last control on each subform I have a code on the Lost focus event, so the next subform comes up automatically and gets the focus.

    This works for the first round. BUt if someone wants do data entry for two separate questionaires then there are problems.

    It seems as though the cursor gets stuck on the last control of tab2 so when it is supposed to setfocus from tab 1 to tab 2 it skips tab 2 and goes straight to tab 3 (because the last control on tab 2 is setfocus to tab 3).

    I have tried to set the focus on a specific control of the tab 2, but when I do that, the cursor will move to the specific control but the Tab won;t pop out and you have to manually click on tab 2.

    Any suggestions would be appreciated! Andlet me know if I can be any clearer!

    Thanks so much,

    Jenny

  2. #2
    Join Date
    Jun 2007
    Location
    Maitland NSW,Australia
    Posts
    388
    Jenny

    I use a button placed at the bottom of the screen called NEXT. I also have an unbound field called page_count and is set to 1 when the form opens with the first tab visible and the remaining tabs not visible.

    When the uer clicks on the NEXT button the page_count field increases by 1 and displays only the second tab. Each time the NEXT button is clicked only the relevant tab is displayed depending on the page_count value.

  3. #3
    Join Date
    Aug 2009
    Posts
    9
    Hi Poppa Smurf,
    Thanks so much for the response.

    I actually attempted this type of thing originally. I put page numbers on each tab, and made a command button (record navigation, next page) to try and make it so it would go to the next page, but that didn;t work, so i must be missing something!

    What would the code,event look like for the button to increase the page by 1? (also make the other two tabs invisible when one is visible).

    Sorry I should have mentioned that access is very new to me and still trying to figure it all out! Thanks again

  4. #4
    Join Date
    Jun 2007
    Location
    Maitland NSW,Australia
    Posts
    388
    Hello Jenny

    1. In the form footer create an unbound text box and call it page_count. This will be used to store the page number.

    2. In the form footer also create a command button call it next_page with the caption Next. This will be used to move the focus from the current tab to the next tab when the user clicks on Next.

    4. Suppose we call your tabs tab_1, tab_2, tab_3 respectively. Now in the Load event of your form add the following code so that only tab_1 is displayed and the other tabs are hidden.

    Sub Form_Load()
    ' set pages to invisible
    tab_2.Visible = False
    tab_3.Visible = False

    ' set page counter
    Me!page_count = 0

    next_page.Visible = True
    end Sub


    3. On the Click event of the Next button add the following code to display each tab when the NEXT button is pressed. The previous tab(s) will be displayed you can hide these if you wish. [field1] is the name of the first field on the respective tab.

    Private Sub next_page_Click()

    Me!page_count = Me!page_count + 1

    Select Case Me!page_count

    Case 1 ' tab_2
    tab_1.Visible = True
    tab_2.Visible = True
    tab_3.Visible = False
    DoCmd.GoToControl "[field1]"

    Case 2 ' tab_3
    tab_1.Visible = True
    tab_2.Visible = True
    tab_3.Visible = True
    DoCmd.GoToControl "[field1]"
    next_page.Visible = False
    End Select

    End Sub

    if you like I could send you as demo version of the above coding.

  5. #5
    Join Date
    Aug 2009
    Posts
    9
    okay, so i tried and I typed in your code (thank you!)

    This is what i have for the command button: (my pages are called Page1 Page2 and Page3).

    Me!page_count = Me!page_count + 1

    Select Case Me!page_count

    Case 1 'Page2
    Page1.Visible = True
    Page2.Visible = True
    Page3.Visible = True
    DoCmd.GoToControl "[host13beh]"

    Case 2 'Page3
    Page1.Visible = True
    Page2.Visible = True
    Page3.Visible = True
    DoCmd.GoToControl "[vom29beh]"
    next_page.Visible = False
    End Select

    End Sub

    This is the code i put in for On load:

    Private Sub Form_Load()
    'set pages to invisible
    Page2.Visible = False
    Page3.Visible = False

    'set page counter
    Me!page_count = 0

    next_page.Visible = True
    End Sub

    It's giving me an error message that microsoft access can;'t find"the field page_count" (I checked the field contrl name, the label is page_count and the TextBox still say Textbox63, but when i try to rename it it says there is already a field with that name so i can;t use it twice, so then i named it page_count2, and it says "object required")

    THere is probably a lot wrong with the code and what i am doing, because when i try to fix one thing, something else pops up.

    Anyway, if you have the patience (i probably woulnd;t) to help me more that would be great! if not, no worries, i am about to give up on this anyway!

    Thanks again,

    Jenny

  6. #6
    Join Date
    Jun 2007
    Location
    Maitland NSW,Australia
    Posts
    388
    It's giving me an error message that microsoft access can;'t find"the field page_count" (I checked the field contrl name, the label is page_count and the TextBox still say Textbox63, but when i try to rename it it says there is already a field with that name so i can;t use it twice, so then i named it page_count2, and it says "object required")
    Rename the label to lbl_count, rename the textbox page_count. If you are still having trouble I will upload a sample database later today.

Posting Permissions

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