![]() |
|
,
0 Comments
)
|
| Subject:
Automatic move to next Access tab page
Category: Computers > Software Asked by: bruces-ga List Price: $15.00 |
Posted:
06 Oct 2002 10:41 PDT
Expires: 05 Nov 2002 09:41 PST Question ID: 73253 |
Im using Access 2002. My database is in Access 2000 format. Im designing a form to collect responses to a 40-item questionnaire. I can fit four list boxes on a screen, so I plan to have 11 tab pages (one page at the end for collecting identifying information) on my form. To ease the task for the user, Id like to have an automatic movement to the next page. For instance, when the user clicks on the choice for Question 4 (the last of the items on Page1), the focus automatically shifts to Question 5 (the first of the items on Page2). I know about entering code as an event procedure. I assume that I need to enter code on the Event tab for the List Box that contains the Question 4 answer. 1. For which Event do I enter the code (After Update, On Enter, On Click)? 2. What code should I enter? 3. Can I use this same method for all of the moves from one page to the next? (I know how to set a command to close the form. My plan is to have a command button on the last page that says, You may review your answers by clicking on the tabs. When you are done, click on the button to close the form.) Thanks. |
|
| Subject:
Re: Automatic move to next Access tab page
Answered By: twitch-ga on 06 Oct 2002 12:56 PDT Rated: ![]() |
bruces-
Thanks for the question. First, I feel that I should caution you that
automatically switching pages when a user selects a value may cause
aggrivation for the user- it will happen so fast that the user will
not always be certain that he or she clicked the appropriate value.
You may want to run the changes by your users to get their feedback.
That being said, there are a couple of ways that you can approach
this- but you probably want to use the Click event to handle your code
in both approaches.
The first option is to have a separate Click event handler for the
last list box on each page that will explicityly set the focus to the
first list box on the next page. The other option, which I favor and
for which the following code applies, is to have a generic Click event
handler that automatically sets the focus to the next page. This
approach, however, requires that you set the TabOrder for each page so
that the appropriate ListBox always has the focus when the Page of the
Tab control switches. The following sample code can be used to
accomplish your goal:
[---------begin code listing-------------]
' a generic subroutine that will handle the click events in the
' proper fashion. we call this routine from every List Box that needs
to
' change the page
Private Sub HandleClick()
Dim thisPage As Control
Set thisPage = Me.ActiveControl.Parent
If thisPage.PageIndex = (tabMyTab.Pages.Count - 1) Then
MsgBox ("You have completed the form")
Exit Sub
End If
tabMyTab.Pages(thisPage.PageIndex + 1).SetFocus
End Sub
[---------end code listing-------------]
With that one routine you can handle the click event in any ListBox
you like. Simply add the following line of code to any ListBox Click
Event handler that needs to be able to switch the page:
Call HandleClick
So if you had a ListBox named List16 its Click event handler would
look like this:
[---------begin code listing-------------]
Private Sub List16_Click()
Call HandleClick
End Sub
[---------end code listing-------------]
Hopefully this solves your problem for you. Please let me know if
there is anything that I might help clarify.
Search strategy
---------------
None, I used my experience with Access and Visual Basic to find a
solution. | |
| |
| |
bruces-ga
rated this answer:
Wonderful answer, but the error in the first response was a bit of a nuisance. |
|
| There are no comments at this time. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
| Search Google Answers for |
| Google Home - Answers FAQ - Terms of Service - Privacy Policy |