tags:

views:

27

answers:

1

I'm using Access 2000, I have a form bound to an updateable query on two tables.

Here's a simplified version of the query:

SELECT tblA.ID AS MainID, tblB.ID, tblA.ItemX, tblB.ItemY
FROM tblA INNER JOIN tblB ON tblA.ID = tblB.ID;

Column tblA.ID is type "autonumber" and is the primary key. Column tblB.ID is long integer, has a unique index, and is required. There is a 1-to-1 "enforce referential integrity" relationship from tblA.ID to tblB.ID.

Let's say the form has text boxes bound to MainID, ID, ItemX, and ItemY. The issue is that if the user starts a new row, enters a value only in ItemX (i.e. nothing to any tblB columns), and does a save, Access only inserts a row into tblA. No row gets inserted into tblB. And then the query cannot subsequently retrieve what was just inserted.

Is this normal Access behavior, or should Access be able to insert a row in tblB with only the newly generated ID value and all other tblB columns null?

+1  A: 

This is normal behavior if the query has the join defined as "Only include rows where hte joined fields from both tables are equal." Try changing the join to "include all records from TableA and only those records from TableB where he joined fields are equal." To change this go into the query in design view and right click on the line leading from TableA to TableB.

Note that a 1 to 1 relationship is generally unusual in database systems. What type of tables are those?

Tony Toews
+1 This does seem like the "right" way, i.e. don't save a row in tblB when the fields are empty anyway. If you really wanted to force the row to be saved, you'd need to add some VB code to set a tblB field and hence make Access think the row needs to be saved. But from a database design point of view, inserting empty rows doesn't make much sense.
Todd Owen
re: what type of tables are those, it's a subtype/supertype arrangement with a system of one tableA and lots of different tableB's. Each tableA/tableB combo has its own updateable query. The system treats each query as a virtual table. Given that this is normal behavior and this issue occurs infrequently, I will take Todd's suggestion and add VBcode to set a tblB field. Thanks for the advice!!
Carlos
In addition to the outer join, there's also the Access-only DISTINCTROW predicate that can help with editable multi-table recordsets.
David-W-Fenton