How to Stop Next Button creating a new record? (1 Viewer)

Bee

Registered User.
Local time
Today, 12:23
Joined
Aug 1, 2006
Messages
487
Hi

I have created a next button that goes to the next record each time the user presses it. however when records finish, it tries to create a new record. Is there anyway to stop it once it reaches the last record. I don't want it used to create new records.

Any suggestions will be very much appreciated.
Thanks,
Reda
 

KeithG

AWF VIP
Local time
Today, 04:23
Joined
Mar 23, 2006
Messages
2,592
In the forms properties set Allow Addtitions to False
 

Bee

Registered User.
Local time
Today, 12:23
Joined
Aug 1, 2006
Messages
487
I want to allow additions in that form, it just not through the next button!
 

Bee

Registered User.
Local time
Today, 12:23
Joined
Aug 1, 2006
Messages
487
Anyone who can help with this will be great.
I basically want to add new records to this form, it just NOT through the next button. There is a linked subform and if the PK went blank on the main form, the database will save a new record without saving the main form's PK for it.
 

DCrake

Remembered
Local time
Today, 12:23
Joined
Jun 8, 2005
Messages
8,626
Simple Software Solutions

Hi

On the OnClick event of the Next button attempt to discover if the user is at the last record in the table. If so, then add the following code

If MsgBox("Are you sure you want to add a new Record?",vbQuestion+vbYesNo,"Add New")=vbYes Then

DoCmd.GoToRecord , , acNewRec

End if

Good Luck!
 

boblarson

Smeghead
Local time
Today, 04:23
Joined
Jan 12, 2001
Messages
32,059
Hi

On the OnClick event of the Next button attempt to discover if the user is at the last record in the table. If so, then add the following code

Sorry, you do not have access to any events through the built-in navigation buttons. Bee - you'll have to create your own nav buttons so you can do this, then set the Navigation Buttons property to NO so the built-in ones don't show up.
 

Bee

Registered User.
Local time
Today, 12:23
Joined
Aug 1, 2006
Messages
487
attempt to discover if the user is at the last record in the table.

I have my own buttons, but I don't know how to find out when it reaches the last record.
 
Last edited:

boblarson

Smeghead
Local time
Today, 04:23
Joined
Jan 12, 2001
Messages
32,059
How about putting this in the click event of the NEXT button(although it may cause it to flicker briefly)
Code:
If Me.NewRecord Then
  DoCmd.RunCommand acCmdRecordsGoToLast
End If
 

Bee

Registered User.
Local time
Today, 12:23
Joined
Aug 1, 2006
Messages
487
That sounds good. Will try it. Cheers.
 

CraigDolphin

GrumpyOldMan in Training
Local time
Today, 04:23
Joined
Dec 21, 2005
Messages
1,582
Another method I have used is

Code:
Private sub CmdNext_Click()
With Recordset
  If .AbsolutePosition = .RecordCount - 1 Then
'you are on the last record
        MsgBox "Sorry, this is the last Record.", vbInformation
  Else
'you are on some other record
        DoCmd.GoToRecord , , acNext
  End If
End With
End Sub

This avoids the flicker issue.
 

Bee

Registered User.
Local time
Today, 12:23
Joined
Aug 1, 2006
Messages
487
That's brilliant CraigDolphin. Cheers.
 

Users who are viewing this thread

Top Bottom