Prevent "next record" button opening a new record

A

Alp Bekisoglu

Hi All,

I know I have seen the answer to this before but can't locate it now. Would
someone re-answer:
How can I prevent my "Next Record" navigation button (nxtBtn) from taking
the user byond the last record into a new record?

I think I should make use of the EOF but couldn't get it to work (most
probably wrong coding). What I am trying to achieve is somewhat similar to a
"previous record" button wher it indicates that there are no prev records.

Thanks in advance,

Alp
 
F

fredg

Hi All,

I know I have seen the answer to this before but can't locate it now. Would
someone re-answer:
How can I prevent my "Next Record" navigation button (nxtBtn) from taking
the user byond the last record into a new record?

I think I should make use of the EOF but couldn't get it to work (most
probably wrong coding). What I am trying to achieve is somewhat similar to a
"previous record" button wher it indicates that there are no prev records.

Thanks in advance,

Alp

Disable the button using code in the Form's Current event when the
last record is reached:

nxtBtn.Enabled = Me.CurrentRecord = 1 Or Me.CurrentRecord <
Me.Recordset.RecordCount
 
W

Wayne Pearson

Hi,

If you're dealing with a Form you could set its Allow Additions property to No
This will disable the new record button on the navigation bar.

Wayne Pearson
 
A

Alp Bekisoglu

Thanks to both of you Wayne and Fred. In the mean time I did come up with
the following under the cmdBtn's click event and would like to have your
comments on it as well if you have the time.

Thanks again.

Alp
Dim sayi As Long
sayi = DMax("y_a_id", "ya_table", "")
If sayi = Me!y_a_id Then
MsgBox "You are already at the last Assessment Year!" & Chr(13) &
Chr(10) & Chr(13) & Chr(10) & "If you are attempting to add a NEW year," &
Chr(13) & Chr(10) & "then you need to do it from the Main Menu.", vbOKOnly,
" MyTAX - Reminder"
Else
DoCmd.GoToRecord , , acNext
End If
 

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