View Full Version : Adding a new record in a Subdatasheet-


phishie
08-14-2008, 09:38 AM
Hey everyone-

I'm having an issue when trying to add new record in a table in the subdatasheet. I'm getting an error that you can't have a null value as the primary key.

I know what the issue stems from but I can't seem to find the solution. The structure is set up like this:

Relationship: [Requirements Table] -1--Many- [Mapping Table] -Many--1- [Dev Object Table]

Table: Requirements Table
Primary Key: BReq #

Table: Dev Object Table
Primary Key: Object ID

Table: Mapping Table
Primary Key: BReq # & Object ID

So when you open the Requirements Table there is a subdatasheet populated with all the Dev Objects mapped to it via the Mapping Table. I want to be able to add new Dev Objects to a Requirement by adding the Dev Object ID in the subdatasheet.

The problem comes when I enter the Dev Object ID and then click out of the cell and get the error. If I unhide columns in the subdatasheet I can see the cell for the BReq # the Dev Object ID should be related to. The problem I've noticed is that, whether hidden or not, the BReq # cell doesn't autopopulate.

Basically it seems the Master BReq # isn't cascading down to the related records in the subdatasheet. I'm lost on how to fix this. Sorry for the long explanation, not sure else how to describe the situation.

Thanks in advance,
Trevor

georgedwilkinson
08-14-2008, 10:13 AM
Check out the Link Child Fields and Link Master Fields on the subform container's property sheet. You can get to it by right clicking on the very edge of the outline of the subform (it takes a little work).

phishie
08-14-2008, 11:26 AM
Check out the Link Child Fields and Link Master Fields on the subform container's property sheet. You can get to it by right clicking on the very edge of the outline of the subform (it takes a little work).

I'm sure where exactly you are referring to clicking. I've tried clicking on the edge of the subdatasheet box and all I get is the standard menu. The only time I get anything related to the Child and Master fields is when I click the "+" and have to choose the query. Those two fields are autopopulated by the Dev Object ID field.

This used to work a while back but I think something isn't right with the query. I can add entries if I unhide the Dev Object ID field in the subdatasheet and fill it in manually but that shouldn't be necessary.

georgedwilkinson
08-14-2008, 11:35 AM
Can you post the DB?

How To Upload A Database To The Forum (http://www.access-programmers.co.uk/forums/showthread.php?t=140587)

phishie
08-14-2008, 12:35 PM
Unfortunately I can't due to proprietary information. On top of that if I make a copy of the db it automatically becomes a replica and the error doesn't show up in a replica. If I make an entry into the subdatasheet in a replica I simply can't move the cursor to another cell and I have to close the table. Once I open the table up again the entry is missing/was never saved.

neileg
08-15-2008, 01:11 AM
Subdatasheets at table level are a complete nightmare. I'd like to ask Microsoft why they though this was a good idea. The better way to handle lookups is in a form, probably a form/subform setup or possibly a combo box. George is assuming you are using a form/subform, but I don't think you are.

georgedwilkinson
08-15-2008, 09:10 AM
OMG, yes, my assumption was that you were using a form/subform. Don't enter data directly into tables!