Next Previous Command buttons

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

Experts,

I need some help with modifying 2 functions "Previous" and "Next"
(navigation buttons for a tab control -- in a form footer)

I thought I had this working properly that now I realize that there is a
small "fluke" with the navigation buttons. I'm wondering if anyone knows
how to modify the functions. I'd be more than happy to post the entire VBA
of frmSurvey but it's pretty lengthy.

Instead, to follow this better, I have posted a small sample db
(PreviousNext.zip) at the following site:
http://tombock2004.i8.com/Test

Here's what's happening:
a. open up frmSurvey
b. on page 1, select any value from the combo box. Then click "Next". This
works fine... I'm now on page 2.
c. on page 2, do the same as in b)... now I'm on page 3.
d. on page 3, do the same as in c)... now I'm on page 4.

Here are the 2 minor problems:
1. once I "navigated" to page 4, the "Next" button is disabled. As long as
I stay on page 4 (last page) it's fine; however, once I move back to either
page 3 or page 2 or page 1, the "Next" button should be enabled again...
just in case I need to go forward one more time.

2. If I moved from pages 1 to 2 to 3 to 4 and then go back to page 1, the
"Previous" button stays enabled on Page 1 (first page).
If I were to click it "Previous" again, I get an error that indicates that
Access can't find Tab 0. Moreover, if I had clicked "End" on the Debug
window and then click "Previous" yet another time, I get the same error
message again... now it indicates that it can't find "Tab -1".


To recap... the function should be written that the following is true:
a. on page 1, only the "Next" button is enabled (whether I go forward for
the 1st time or I've come back to page 1)
b. pages 2 and 3 are ok
c. on page 3, the "Next" button should disabled... however, based on the
criteria in b), "Next" must be enabled again once I navigate back from page
4 to page 3.

If you feel comfortable downloading the sample file (as posted at the
beginning of the message), the process can be easily followed.

I appreciate any help that would solve this problem.

Thanks,
Tom
 
Tom,

No need to change the functions at all. Just use the Tab Control's
Change event to test which tab you are on and then enable/disable
the appropriate buttons.

Like so:

Private Sub TabControl1_Change()
On Error GoTo ErrorPoint

Select Case Me.TabControl1
Case 0
' First tab, set focus to frame
' and then disable Previous button
Me.Frame1.SetFocus
Me.Previous.Enabled = False
Me.Next.Enabled = True
Case 1
' Second tab, both buttons OK
Me.Previous.Enabled = True
Me.Next.Enabled = True
Case 2
' Third tab, both buttons OK
Me.Previous.Enabled = True
Me.Next.Enabled = True
Case 3
' Fourth tab, set focus to frame
' and then disable Next button
Me.Frame4.SetFocus
Me.Previous.Enabled = True
Me.Next.Enabled = False
Case Else
' Nothing, should not get here
End Select

ExitPoint:
Exit Sub

ErrorPoint:
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " & Err.Description _
, vbExclamation, "Unexpected Error"
Resume ExitPoint

End Sub

Just copy/paste that code in and you should be all set.

--
Jeff Conrad
Access Junkie
http://home.bendbroadband.com/conradsystems/accessjunkie.html
http://www.access.qbuilt.com/html/articles.html

in message:
 
in message:
Jeff:

That's absolutely perfect!!!
Sweet.

Thanks so much for the quick response.

You're welcome, glad I could help.
And thank you for posting a well written question and
offering a site to download as an option.
 
Back
Top