Navigation buttons add blank records (1 Viewer)

jpl458

Well-known member
Local time
Today, 11:41
Joined
Mar 30, 2012
Messages
1,059
I have a form whose record source is a query that sets the order of the data viewed on the form. I use the built in scrolling buttons to move back ad forth through the data. If data is changed in a record it will cause non visible controls to appear, after the changes, and when I move to the next record, I clear the now visible controls buy making them not visible in the OnCurrent event. But when I get to the last record and keep hitting the next record button, it adds neww, blank records to the table. How do I prevent that? Can it be done with events or is code involved. I have just read this:

When you move the focus to a new (blank) record on a form and then create a new record by typing data in a control, the following sequence of events occurs:

Current (form)
arrow
Enter (control)
arrow
GotFocus (control)
arrow
BeforeInsert (form)
arrow
AfterInsert (form)

But they seem to only apply if data is entered. I would like to always have one blank record for entering new data, but don't want the blank records written to the table.

Thanks
 

June7

AWF VIP
Local time
Today, 10:41
Joined
Mar 9, 2014
Messages
5,505
What do you mean by 'blank' record? If data input has occurred then record is initiated and will be committed when moving to another row. If for some reason you don't want this record to commit, then you need to do data validation in form BeforeUpdate event and cancel if condition is met.
 

jpl458

Well-known member
Local time
Today, 11:41
Joined
Mar 30, 2012
Messages
1,059
What do you mean by 'blank' record? If data input has occurred then record is initiated and will be committed when moving to another row. If for some reason you don't want this record to commit, then you need to do data validation in form BeforeUpdate event and cancel if condition is met.
I mean a record with no data in it. if I scroll through the dat to the end, and keep scrolling new records are created that have what is in the text boxes, which is nothing. Also noted that duplicate auto numbers are created for the rows that are empty.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 13:41
Joined
Feb 28, 2001
Messages
27,517
In File >> Options >> Current Database, check the value for "CYCLE" which can have this effect, depending exactly on how you are scrolling. Also, there may be other settings near that area of DB options that are related to form navigation and thus could control this effect.
 

jpl458

Well-known member
Local time
Today, 11:41
Joined
Mar 30, 2012
Messages
1,059
Allow Addition = No. That does the trick
In File >> Options >> Current Database, check the value for "CYCLE" which can have this effect, depending exactly on how you are scrolling. Also, there may be other settings near that area of DB options that are related to form navigation and thus could control this effect.
Thanks, I'll take a look at that.,
why would you add blank records?
It wasn't intentional, and I din't want it to happen. Unless I find a use that wants to pay by the record.
 

June7

AWF VIP
Local time
Today, 10:41
Joined
Mar 9, 2014
Messages
5,505
In File >> Options >> Current Database, check the value for "CYCLE" which can have this effect, depending exactly on how you are scrolling. Also, there may be other settings near that area of DB options that are related to form navigation and thus could control this effect.
I don't see a CYCLE property in File>Options>Current Database. This is a property of form.

I cannot replicate this issue.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 14:41
Joined
Feb 19, 2002
Messages
43,774
But when I get to the last record and keep hitting the next record button, it adds neww, blank records to the table. How do I prevent that?
You have code in one of those events that is dirtying the record. AND you have NO validation code in the Form's BeforeUpdate event to prevent bad data from being saved.

Please paste the code from the entire form's code module and we'll find the bad code.

OR - if you are feeling adventurous - download the database from this link and import your form and table and query. It wouldn't hurt to watch the videos to learn about validation as well.
 

Users who are viewing this thread

Top Bottom