Search code examples
vbams-access

Create New Record statement on Record Next button


I want to add an if clause on one of my buttons.

I have the general "Cycle Next" button running VBA on most of my user forms, but my users have a habit of using it to create a new record instead of using the "New Record" button.

Is there any way to check if they're on the last record & if so, create a new record using my call "New Record" VBA?

I have specific VBA that runs on the "New Record" button that needs to be added to the form & they spam the "Cycle Next" button creating 3-4 unnecessary new records. I'll probably add a message box that tells them they're creating a new record to fix that issue.


Solution

  • Use the OnCurrent event of the form:

    Me!CycleNextButton.Enabled = (Me.CurrentRecord <> Me.RecordsetClone.RecordCount)