Subform Foreign key not working

  • Thread starter abefuzzleduser2
  • Start date
A

abefuzzleduser2

We use Access 2000 with linked tables in SQL Server 2000. I have a
form and a
datasheet subform based on two tables. I was adding FK/PK relation and
some Foreign keys POIDs were NULL? tblPO has a one to many relation
between items with POID as PK in tblPO and FK in items. I have
verified the SUBFORM is using POID for parent and child. I see the new
row asterick on subform so I can add new rows. The subform has Item,
Description, Qty, Code (DROPdown list) and resolved checkbox. The
parent data row already has been entered but every time I try to add a
new data in subform I get error "ODBC-- call failed. the cannot insert
NULL into column POID, column does not allow
nulls. insert fails"? one other strange problem I started getting error
lately "The value you entered isn't valid for this field" when I start
typing in the subform?? Maybe that is part of the problem???
The SAME subform works on a different form and updates FK just fine.
The
subform that works, main form query gets tblPO on the outer join. The
one that
does not work uses tblPO the non-outer side for main form. Subforms
are
setup the same (the form that worked was hooked directly to table no
query). See queries at bottom.
Subform has
Item (textbox), Description (textbox), Qty (textbox), Code (static
DROPdown list) and resolved (checkbox).

CREATE TABLE [dbo].[tblPODiscrepancyItems] (
[PODiscID] [int] IDENTITY (1, 1) NOT NULL ,
[POID] [int] NULL ,
[Item] [nvarchar] (50) NULL ,
[Description] [nvarchar] (50) NULL,
[Qty] [int] NULL ,
Code:
 [nvarchar] (50) NULL ,
[Resolved] [bit] NULL
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[tblPurchaseOrder] (
[POID] [int] IDENTITY (1, 1) NOT NULL ,
[Date] [datetime] NULL ,
[DocNumber] [nvarchar] (20)  NULL ,
....

I dont use any validation , defaults etc. I was able to add add data
directly to
Items table.  I created a new sub form based on a query with 5 plain
text boxes but I
still got the same errors. It is linked to main form like others on
POID.
Should not have any defaults or validation? Item, Description, Qty,
Code and resolved checkbox.

Nonworking query
SELECT tblPurchaseOrder.*, tblOrder.SOPNUMBE, tblOrder.CUSTNMBR,
tblOrder.ShipDate, tblOrder.ShipToName, tblOrder.Ordercntr,
tblPurchaseOrder.PODiscrepIndicator, tblOrder.CUSTNAME,
tblPurchaseOrder.RepairSNEmailed, tblOrder.FirstShipmentDate
FROM tblPurchaseOrder LEFT JOIN tblOrder ON tblPurchaseOrder.OENumber =
tblOrder.SOPNUMBE
ORDER BY tblPurchaseOrder.POID;

WOrking query
SELECT qryOrder2System.*, tblPurchaseOrder.Location,
tblPurchaseOrder.PODiscrepDate, tblPurchaseOrder.PODiscrepIssuer,
tblPurchaseOrder.PODeliveryCarrier,
tblPurchaseOrder.PODeliveryTrackNumber,
tblPurchaseOrder.PODiscrepComment,
tblPurchaseOrder.PODiscrepPurchasingInitials,
tblPurchaseOrder.PODiscrepCredAmt, tblPurchaseOrder.PODiscrepBalDue,
tblPurchaseOrder.PODiscrepVendNotifiedDate,
tblPurchaseOrder.PODiscrepCreditNumber,
tblPurchaseOrder.PODiscrepNewPONum,
tblPurchaseOrder.PODiscrepResolvedDate,
tblPurchaseOrder.PODiscrepPurchComment, tblPurchaseOrder.POID,
tblPurchaseOrder.PODateCompleted, tblPurchaseOrder.PODateCompleted,
tblPurchaseOrder.ArrivalDate
FROM qryOrder2System LEFT JOIN tblPurchaseOrder ON
qryOrder2System.DocNumber = tblPurchaseOrder.DocNumber
ORDER BY qryOrder2System.SystemID;

Help I am stuck and out of ideas??
 

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