Blank records are being inserted into table via subform

  • Thread starter Thread starter GB via AccessMonster.com
  • Start date Start date
G

GB via AccessMonster.com

Hello,
This forum has been very helpful to my in designing my application, but this
newest problem has me stumped and I'm sure it's because I'm a newbie.

I have designed a subform (Access 2000) that is bound to the main form using
the following fields:

Link Child Fields: Employee_ID;Supervisor_id;Begin_Period;End_Period (key
fields)
Link Master Fields: cbolookup;Supervisor_id;Begin_Period;End_Period

When I select an Employee_ID from the combo box (cbolookup) on my main form,
the correct record is displayed on the subform and I am able to update and
delete the record. If there is no matching record, the subform displays a
"blank" record but pre-populates the Link Child fields (based on info
gathered from the main form).

These "blank" records are being automatically inserted into the table even if
I'm not pressing the add button. The fact that it was displayed seems to
trigger an add. Can anyone tell me how to avoid this? I would like to
continue having the above fields already filled with data on the subform if
possible.

I'm not sure what other information to provide.
Thank You,
GB
 
GB,
I'm a bit curious as to why you have so many Child/Master links. It
wouls seem as though EmpoloyeeID should be all you need to associate all the
subform records to that employee. Supervisor should usually be associated
to the employee through the Main form employee data. Also, are BeginPeriod
and EndPeriod really "key" fields? I would think data of that nature would
apply to many employees.
I'm not saying it's incorrect, but it caught my attention as being a bit
unusual... you make the call. And, having so many links may be contributing
to this very problem.

You wroteExactly.
Your subform is entering some preset/default values into any new record
in your subform, and as the subform records come up there is an Update or
Refresh or perhaps a Requery that is "setting" those values and creating a
seemingly empty record.
Can you see the default/link values dsiplayed on the subform? If you hit
{esc}when you first open the sub do those values disappear? If not, then
probably something has programatically caused the default values or link
field values to update.

hth
Al Camp
 
Hi Al,

I initially had Employee_ID and cbolookup as the only Master/Child links but
I kept encountering an error that indicated I was inserting duplicates so I
changed it. The key to my table is Employee_ID, Supervisor_ID, Begin_Period,
End_Period. That's in order to avoid duplicates records for each employee's
monthly input.

I don't have any refresh, requery or update statements at all in either form.
The default link values are the master/child links? If so, yes, those are
showing up on the subform already populated even if there is no record in the
table and they won't disappear when I hit the esc key (so I'm updating those
fields because of the setup of the link fields I think). Is the fact that
those fields are already filled in the reason for the records automatically
being inserted to the table?

Thanks for responding!

Al said:
GB,
I'm a bit curious as to why you have so many Child/Master links. It
wouls seem as though EmpoloyeeID should be all you need to associate all the
subform records to that employee. Supervisor should usually be associated
to the employee through the Main form employee data. Also, are BeginPeriod
and EndPeriod really "key" fields? I would think data of that nature would
apply to many employees.
I'm not saying it's incorrect, but it caught my attention as being a bit
unusual... you make the call. And, having so many links may be contributing
to this very problem.

You wroteExactly.
Your subform is entering some preset/default values into any new record
in your subform, and as the subform records come up there is an Update or
Refresh or perhaps a Requery that is "setting" those values and creating a
seemingly empty record.
Can you see the default/link values dsiplayed on the subform? If you hit
{esc}when you first open the sub do those values disappear? If not, then
probably something has programatically caused the default values or link
field values to update.

hth
Al Camp
Hello,
This forum has been very helpful to my in designing my application, but
[quoted text clipped - 27 lines]
Thank You,
GB
 
P.S I have set the subform up with Save and Delete buttons in order to
interact with the records. I'm able to use those with no problem.

Al said:
GB,
I'm a bit curious as to why you have so many Child/Master links. It
wouls seem as though EmpoloyeeID should be all you need to associate all the
subform records to that employee. Supervisor should usually be associated
to the employee through the Main form employee data. Also, are BeginPeriod
and EndPeriod really "key" fields? I would think data of that nature would
apply to many employees.
I'm not saying it's incorrect, but it caught my attention as being a bit
unusual... you make the call. And, having so many links may be contributing
to this very problem.

You wroteExactly.
Your subform is entering some preset/default values into any new record
in your subform, and as the subform records come up there is an Update or
Refresh or perhaps a Requery that is "setting" those values and creating a
seemingly empty record.
Can you see the default/link values dsiplayed on the subform? If you hit
{esc}when you first open the sub do those values disappear? If not, then
probably something has programatically caused the default values or link
field values to update.

hth
Al Camp
Hello,
This forum has been very helpful to my in designing my application, but
[quoted text clipped - 27 lines]
Thank You,
GB
 
GB,
Right now, I have to say that there's a problem in your design. Since
those link values can't be {esc}'d that record has been created.
If the data in your subform is a one to many realtionship with the
employee, then that's all you should need for a link.
I initially had Employee_ID and cbolookup as the only Master/Child links
but
I kept encountering an error that indicated I was inserting duplicates...
That problem should be solved first. And, a cboLookUp combo box should
not be involved at all either.

EmployeeID in tblEmployees should be Key/Indexed/NoDupes. In your
subform table you should have EmployeeID - Indexed/DupesOK. That should
allow a One to Many link in Relationships and provide Referential Integrity.
I really think this problem might be solved by using utilizing a more
standard linking scheme.

*I know many on this NG would bark at linking 2 tables by a field
(EmployeeID) that is "user editable", but I just want to deal with the
basics right now.
If that solves your problem, you can post back a new thread on the
"ideal" table design for more discussion.
hth
Al Camp

GB via AccessMonster.com said:
Hi Al,

I initially had Employee_ID and cbolookup as the only Master/Child links
but
I kept encountering an error that indicated I was inserting duplicates so
I
changed it. The key to my table is Employee_ID, Supervisor_ID,
Begin_Period,
End_Period. That's in order to avoid duplicates records for each
employee's
monthly input.

I don't have any refresh, requery or update statements at all in either
form.
The default link values are the master/child links? If so, yes, those are
showing up on the subform already populated even if there is no record in
the
table and they won't disappear when I hit the esc key (so I'm updating
those
fields because of the setup of the link fields I think). Is the fact that
those fields are already filled in the reason for the records
automatically
being inserted to the table?

Thanks for responding!

Al said:
GB,
I'm a bit curious as to why you have so many Child/Master links. It
wouls seem as though EmpoloyeeID should be all you need to associate all
the
subform records to that employee. Supervisor should usually be associated
to the employee through the Main form employee data. Also, are
BeginPeriod
and EndPeriod really "key" fields? I would think data of that nature
would
apply to many employees.
I'm not saying it's incorrect, but it caught my attention as being a
bit
unusual... you make the call. And, having so many links may be
contributing
to this very problem.

You wrote
but pre-populates the Link Child fields
Exactly.
Your subform is entering some preset/default values into any new record
in your subform, and as the subform records come up there is an Update or
Refresh or perhaps a Requery that is "setting" those values and creating a
seemingly empty record.
Can you see the default/link values dsiplayed on the subform? If you
hit
{esc}when you first open the sub do those values disappear? If not, then
probably something has programatically caused the default values or link
field values to update.

hth
Al Camp
Hello,
This forum has been very helpful to my in designing my application, but
[quoted text clipped - 27 lines]
Thank You,
GB
 
Back
Top