Next page, Previuous page and First Page cmd buttons

G

Guest

I have a form with 8 pages tab. I have a code (in each page) to skip to next
page and so on to 7:
Private Sub Command15_Click()
With TabCtl0
If .Value = .Pages.Count - 1 Then
' It's the last page, so go back to the first page.
..Value = 0
Else
..Value = .Value + 1
End If
End With
End Sub

I need 2 more cmd buttons. One to skip to previous page (in each page)and
another one to to go back from last page to first page.

Does any body could help me? Many thanks
 
S

Steve

To skip to previous page ---
You only need one button outside the tabcontrol with the following code in
the click event:
If Me!Tabctl0.Value = 0 Then
Msgbox "On First Page"
Else
Me!Tabctl0.Value = Me!Tabctl0.Value - 1
End If


To go back from last page to first page ---
You only need one button outside the tabcontrol with the following code in
the click event:
If Me!Tabctl0.Value = 0 Then
Msgbox "On First Page"
Else
Me!Tabctl0.Value = 0
End If



PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 
G

Guest

You almost have it.

Private Sub cmdNextPage_Click()
With TabCtl0
If .Value = .Pages.Count - 1 Then
' It's the last page, so go back to the first page.
.Value = 0
Else
.Value = .Value + 1
End If
End With
End Sub

Private Sub cmdPreviousPage_Click()
With TabCtl0
If .Value = 0 Then
' It's the firstst page, so go to the last page.
.Value = .Pages.Count -1
Else
.Value = .Value - 1
End If
End With
End Sub

BTW, notice the indentation. Isn't that much easier to read?
 
G

Guest

Steve said:
To skip to previous page ---
You only need one button outside the tabcontrol with the following code in
the click event:
If Me!Tabctl0.Value = 0 Then
Msgbox "On First Page"
Else
Me!Tabctl0.Value = Me!Tabctl0.Value - 1
End If


To go back from last page to first page ---
You only need one button outside the tabcontrol with the following code in
the click event:
If Me!Tabctl0.Value = 0 Then
Msgbox "On First Page"
Else
Me!Tabctl0.Value = 0
End If



PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)







Great. Thank you very much
 
G

Guest

It Works!!!Thank you very much indeed.

Klatuu said:
You almost have it.

Private Sub cmdNextPage_Click()
With TabCtl0
If .Value = .Pages.Count - 1 Then
' It's the last page, so go back to the first page.
.Value = 0
Else
.Value = .Value + 1
End If
End With
End Sub

Private Sub cmdPreviousPage_Click()
With TabCtl0
If .Value = 0 Then
' It's the firstst page, so go to the last page.
.Value = .Pages.Count -1
Else
.Value = .Value - 1
End If
End With
End Sub

BTW, notice the indentation. Isn't that much easier to read?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top