Records added when using tab

  • Thread starter Thread starter John Michael
  • Start date Start date
J

John Michael

I have a form that is used to add new records to a table. When I tab
through the form if I don't fill out the required fields, when I hit the
last command button which is that last one in the tab order that I have set
to cancel and close the form, it will add the record to the table even
though I have not pushed any command button to save the record. Again, I am
only tabbing through the form. It automatically adds the record and clears
the form for another record to be entered before going back to the first tab
index 0. If a required field in the form is not filled, I will get the
error that the field is required.

Why won't it just go to the tab index 0. If the form is filled out and I
tab through the cancel button, it will still save the record even if I add:
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
to the cancel button event proceedure for that command button. The record
has already been added. IF I don't tab through it, it will not save the
record.

How can I stop this.
I have
Allow Additions & Data Entry set to Yes.

I guess I could I remove the Record Source property and update the table
using SQL and VB.


Also, I have seen in one of my books that there is a form property in the
data tab,
Commit On Close
but it doesn't show up on my computer.
I am using Access 2002

Thanks in advance
This news group is excellent. Could not get along without it.
John Michael
 
John Michael said:
I have a form that is used to add new records to a table. When I tab
through the form if I don't fill out the required fields, when I hit
the last command button which is that last one in the tab order that
I have set to cancel and close the form, it will add the record to
the table even though I have not pushed any command button to save
the record. Again, I am only tabbing through the form. It
automatically adds the record and clears the form for another record
to be entered before going back to the first tab index 0. If a
required field in the form is not filled, I will get the error that
the field is required.

Why won't it just go to the tab index 0. If the form is filled out
and I tab through the cancel button, it will still save the record
even if I add: DoCmd.DoMenuItem acFormBar, acEditMenu,
acUndo, , acMenuVer70
to the cancel button event proceedure for that command button. The
record has already been added. IF I don't tab through it, it will
not save the record.

How can I stop this.
I have
Allow Additions & Data Entry set to Yes.

I guess I could I remove the Record Source property and update the
table using SQL and VB.

I'm guessing that there are three factors contributing to this behavior.

1. Access will always attempt to save a "dirty" record -- i.e., one that
has been modified but not saved -- when you close the form or move to a
new record. Note that Access will never attempt to save a record that
it doesn't think is dirty.

2. If you have the form's Cycle property set to "All Records" (on the
Other tab of the form's property sheet in design view), tabbing out of
the last control in the tab order will cause the form to move to a new
record unless you're already on a new record *and that record is not
dirty*.

3. Since Access won't save a record that isn't dirty, and yet you say
the record is being saved without your having modified any controls, you
must have code (or a macro) being executed in some event that is
dirtying the form. In other words, some code is modifying the value of
a bound control. If you post the complete code from the form's module,
we can probably figure out what's doing it.

I'm not sure what you're saying about "If the form is filled out and I
tab through the cancel button, it will still save the record even if I
add: DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70 to
the cancel button event proceedure for that command button." Tabbing
through a button doesn't cause the button's Click event procedure to
run. If you're saying that *clicking* the button, or tabbing to it and
then pressing Enter, doesn't undo the form as it should, the only thing
I can think of is that the form has already been saved. Let's see the
form's code module.
Also, I have seen in one of my books that there is a form property in
the data tab,
Commit On Close
but it doesn't show up on my computer.
I am using Access 2002

This property is mentioned in the help system, but was never actually
implemented in Access 2002. It's not alone; see Microsoft
KnowledgeBase article 293334:

http://support.microsoft.com/default.aspx?scid=kb;en-us;293334

I don't know offhand whether it exists in Access 2003.
 
Thanks for your reply.

Setting the Cycle property like you suggested to current record solved the
problem.

Thanks Again
John michael
 

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

Back
Top