Next Record keeps making new record even if nothing entered on for

G

Guest

I have a form that is just using the default record navigation buttons. My
problem is that when I get to the last record and click move next it creates
a new record. I know that this is how it is supposed to work, but my problem
is that it does not then disable the next or new record buttons and
subsequent presses of either button save the blank record that was previously
created even though I had not entered any values on the form, for that
matter, I had not even moved the mouse away from the next record button. I
get the same issue if I use the delete record button from the access toolbar.
It deletes the record, but creates a new one right after the deletion. If I
click delete again, it deltes the new record it just made on the last delete,
but it then make another new record.

The fields that get populated on the record are an autonumber key, a field
that is to default to today's date, 2 numeric fields that default to 0 and a
yes/no field that defaults to no.

All of these defaults are on the underlying table, not on the form. So they
should not be the issue.

If I add the following code it will just make one new record and save it
before it diables making new records, but that is still one too many as I
know the users here will always just keep clicking next until they are not
able to do so.

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.cboNCRType = "" Or IsNull(Me.cboNCRType) Then
DoCmd.RunCommand acCmdUndo
End If
End Sub

cboNCRType is the first field that people need to enter to get the rest of
the form to function, so it is a good one to use to make sure that the record
either should or should not be saved.

Any help would be greatly appreciated!!!!!
 
D

Dirk Goldgar

Groucho said:
I have a form that is just using the default record navigation
buttons. My problem is that when I get to the last record and click
move next it creates a new record. I know that this is how it is
supposed to work, but my problem is that it does not then disable the
next or new record buttons and subsequent presses of either button
save the blank record that was previously created even though I had
not entered any values on the form, for that matter, I had not even
moved the mouse away from the next record button. I get the same
issue if I use the delete record button from the access toolbar. It
deletes the record, but creates a new one right after the deletion.
If I click delete again, it deltes the new record it just made on the
last delete, but it then make another new record.

The fields that get populated on the record are an autonumber key, a
field that is to default to today's date, 2 numeric fields that
default to 0 and a yes/no field that defaults to no.

All of these defaults are on the underlying table, not on the form.
So they should not be the issue.

If I add the following code it will just make one new record and save
it before it diables making new records, but that is still one too
many as I know the users here will always just keep clicking next
until they are not able to do so.

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.cboNCRType = "" Or IsNull(Me.cboNCRType) Then
DoCmd.RunCommand acCmdUndo
End If
End Sub

cboNCRType is the first field that people need to enter to get the
rest of the form to function, so it is a good one to use to make sure
that the record either should or should not be saved.

Any help would be greatly appreciated!!!!!

What you describe is not normal behavior, so I suspect you have code
that is dirtying the record, probably in the form's Current event. Do
you have code (or a macro) running in that event? If so, what is it?
 
G

Guest

Thanks for pointing me towards the obvious! Some times the simplest
solutions are the hardest to find.

I don't know why I missed it. I do have the current event setting some
field values. Now I just have to go through the 9 pages of code behind that
form and see where to move stuff to have it still function properly without
having the unwanted behaviour. It would be much easier if my boss didn't
want almost every control to be filled, cleared, or made invisible bassed on
what was entered in a previous control.

Groucho
 
D

Dirk Goldgar

Groucho said:
Thanks for pointing me towards the obvious! Some times the simplest
solutions are the hardest to find.

I don't know why I missed it. I do have the current event setting
some field values. Now I just have to go through the 9 pages of code
behind that form and see where to move stuff to have it still
function properly without having the unwanted behaviour. It would be
much easier if my boss didn't want almost every control to be filled,
cleared, or made invisible bassed on what was entered in a previous
control.

Maybe you can fulfill his requirements by setting the default values of
controls, rather then their values.
 
G

Guest

No, it worked out fine. I just had to rember that I don't need things to
appear or disappear relating to old data, which is what I was doing. Once I
clean the tables out and start using the system, the filling of certain
fields, based on the entries in previous fields can be set at the change of
the previous field instead of in the current event which I had used to have
it update old data.

Thanks again.
 

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