Show botton "Go to next record"

G

Guest

Hi
I have this button "Go to next record"
On Error GoTo Err_Kommandoknap37_Click


DoCmd.GoToRecord , , acNext

Exit_Kommandoknap37_Click:
Exit Sub

Err_Kommandoknap37_Click:
MsgBox Err.Description
Resume Exit_Kommandoknap37_Click

But i will only have the button to show when thre are a next record
so when i'm on the last record don't show the button
how can i do this?

Regards
Alvin
 
S

Sandra Daigle

Take a look at the RecordNavigationButtons sample at
http://www.lebans.com/recnavbuttons.htm. This mdb has a simple subform that
you can put onto any form and and with some minor vba you don't have to do
anything extra. Basically what it does is use the recordsetclone, attempt
to scroll forward a row - if you get the EOF condition you are at the EOF
and so the Next button is disabled. Starting back at the current record, it
also tries to move backwards - if BOF is true then the current record is the
first so the Previous button is disabled.
 
F

fredg

Hi
I have this button "Go to next record"
On Error GoTo Err_Kommandoknap37_Click

DoCmd.GoToRecord , , acNext

Exit_Kommandoknap37_Click:
Exit Sub

Err_Kommandoknap37_Click:
MsgBox Err.Description
Resume Exit_Kommandoknap37_Click

But i will only have the button to show when thre are a next record
so when i'm on the last record don't show the button
how can i do this?

Regards
Alvin

The below will disable the Previous button when it's on the first
record as well as disable the Next button when it is at the last
record.

Private Sub Form_Current()

CmdPreviousRecord.Enabled = Not Me.CurrentRecord = 1
CmdNextRecord.Enabled = Me.CurrentRecord = 1 Or Me.CurrentRecord <
Me.Recordset.RecordCount

End Sub

You can change .Enabled to .Visible if you want to hide the button
completely instead of graying it out.
 
G

Guest

Thansk
but i would like to do something for my self
too understand this

alvin


Sandra Daigle said:
Take a look at the RecordNavigationButtons sample at
http://www.lebans.com/recnavbuttons.htm. This mdb has a simple subform that
you can put onto any form and and with some minor vba you don't have to do
anything extra. Basically what it does is use the recordsetclone, attempt
to scroll forward a row - if you get the EOF condition you are at the EOF
and so the Next button is disabled. Starting back at the current record, it
also tries to move backwards - if BOF is true then the current record is the
first so the Previous button is disabled.

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


alvin said:
Hi
I have this button "Go to next record"
On Error GoTo Err_Kommandoknap37_Click


DoCmd.GoToRecord , , acNext

Exit_Kommandoknap37_Click:
Exit Sub

Err_Kommandoknap37_Click:
MsgBox Err.Description
Resume Exit_Kommandoknap37_Click

But i will only have the button to show when thre are a next record
so when i'm on the last record don't show the button
how can i do this?

Regards
Alvin
 
F

fredg

Can't get it to work
Where do i put this code in?

Sorry not so god at thise

Alvin

fredg said:
The below will disable the Previous button when it's on the first
record as well as disable the Next button when it is at the last
record.

Private Sub Form_Current()

CmdPreviousRecord.Enabled = Not Me.CurrentRecord = 1
CmdNextRecord.Enabled = Me.CurrentRecord = 1 Or Me.CurrentRecord <
Me.Recordset.RecordCount

End Sub

You can change .Enabled to .Visible if you want to hide the button
completely instead of graying it out.

It goes in the form's Current event.
Private Sub Form_Current() <
Change CmdPreviousRecord and CmdNextRecord to whatever your actual
command button names are.
 
S

Sandra Daigle

No problem but you still might want to look at the database to see one
method for doing this. Otherwise you can use the method that Fred
recommended.

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


alvin said:
Thansk
but i would like to do something for my self
too understand this

alvin


Sandra Daigle said:
Take a look at the RecordNavigationButtons sample at
http://www.lebans.com/recnavbuttons.htm. This mdb has a simple
subform that you can put onto any form and and with some minor vba
you don't have to do anything extra. Basically what it does is use
the recordsetclone, attempt to scroll forward a row - if you get the
EOF condition you are at the EOF and so the Next button is disabled.
Starting back at the current record, it also tries to move
backwards - if BOF is true then the current record is the first so
the Previous button is disabled.

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


alvin said:
Hi
I have this button "Go to next record"
On Error GoTo Err_Kommandoknap37_Click


DoCmd.GoToRecord , , acNext

Exit_Kommandoknap37_Click:
Exit Sub

Err_Kommandoknap37_Click:
MsgBox Err.Description
Resume Exit_Kommandoknap37_Click

But i will only have the button to show when thre are a next record
so when i'm on the last record don't show the button
how can i do this?

Regards
Alvin
 
G

Guest

Thansk
now i get it

Alvin

fredg said:
Can't get it to work
Where do i put this code in?

Sorry not so god at thise

Alvin



It goes in the form's Current event.
Change CmdPreviousRecord and CmdNextRecord to whatever your actual
command button names are.
 

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

Similar Threads


Top