moving between pages on tab control (new user)

G

Guest

Hi,
1) I would like to make a command button that allows a user to move to the
next page on a tab control. I know this question is already answered and I
am supposed to use this code:
With Me.tabMyTabControl
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

But I am a new user and not familiar with the codes so where do I insert
this? Do I need to make a button using the wizard and then insert this
somewhere in Microsoft's code?

I was also wondering how to get the focus to move automatically from the last
control on one page to the first control on the next page.

2) Another problem I am having is that I want to print one page at a time,
but when I press the print record button, it prints everything out. This is
because all the tabs are on one record, but there isn't any other option in
the command buttom wizard. Is there a way to print only one tab at a time?

Sorry this is so long. I would be grateful for any help.
Thank you,
Nicole
 
R

Rick Brandt

colesterg said:
Hi,
1) I would like to make a command button that allows a user to move
to the next page on a tab control. I know this question is already
answered and I am supposed to use this code:
With Me.tabMyTabControl
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

But I am a new user and not familiar with the codes so where do I
insert this? Do I need to make a button using the wizard and then
insert this somewhere in Microsoft's code?

Drop a button on your form with the toolbox wizard turned off, name the button
what you want, and then in the property sheet for the button go to the events
tab and find the OnClick property. In the drop list of choices choose [Event
Procedure] and then press the build button [...] to the right.

That will take you to the VBA code window and *that* is where you code goes.
I was also wondering how to get the focus to move automatically from
the last control on one page to the first control on the next page.

Place a very small (but visible=true) TextBox on each page and make it last in
the TabOrder. In its GotFocus event have code...

Me.ControlName.SetFocus

....where ControlName is the name of the desired control on the desired TabPage.
2) Another problem I am having is that I want to print one page at a
time, but when I press the print record button, it prints everything
out. This is because all the tabs are on one record, but there isn't
any other option in the command buttom wizard. Is there a way to
print only one tab at a time?

Don't print forms, create a report and print that. It is easy to open or print
a report pre-filtered to the record currently being displayed on the form by
using the WHERE argument of the OpenReport method.

DoCmd.OpenReport "ReportName",,,,"PrimaryKeyField = " & Me!PrimaryKeyField
 
S

steveoz

Rick said:
colesterg said:
Hi,
1) I would like to make a command button that allows a user to move
to the next page on a tab control. I know this question is already
answered and I am supposed to use this code:
With Me.tabMyTabControl
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

But I am a new user and not familiar with the codes so where do I
insert this? Do I need to make a button using the wizard and then
insert this somewhere in Microsoft's code?

Drop a button on your form with the toolbox wizard turned off, name the button
what you want, and then in the property sheet for the button go to the events
tab and find the OnClick property. In the drop list of choices choose [Event
Procedure] and then press the build button [...] to the right.

That will take you to the VBA code window and *that* is where you code goes.
I was also wondering how to get the focus to move automatically from
the last control on one page to the first control on the next page.

Place a very small (but visible=true) TextBox on each page and make it last in
the TabOrder. In its GotFocus event have code...

Me.ControlName.SetFocus

...where ControlName is the name of the desired control on the desired TabPage.
2) Another problem I am having is that I want to print one page at a
time, but when I press the print record button, it prints everything
out. This is because all the tabs are on one record, but there isn't
any other option in the command buttom wizard. Is there a way to
print only one tab at a time?

Don't print forms, create a report and print that. It is easy to open or print
a report pre-filtered to the record currently being displayed on the form by
using the WHERE argument of the OpenReport method.

DoCmd.OpenReport "ReportName",,,,"PrimaryKeyField = " & Me!PrimaryKeyField
 

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