1) I have "witnessed" the instance wher the user enters the data and at once:
The Priamry Key is removed, the one to many relationship is changed to a
"one to many", and the database is corrupted / crashes.
The form is entring ddata into 3 tables on the close of the form, following
is the code that I have.
Thank you
Nelson
[Item#].SetFocus
If [Item#].Text = "" Then
intVBResponse = MsgBox("You did not indicate an item number for this
shipment, do you want to cancel this order? ", vbYesNo, "Missing Information")
If intVBResponse = vbYes Then
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
DoCmd.Close
Else
Exit Sub
End If
Else
DoCmd.SetWarnings False
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.RunSQL "INSERT INTO tblConsignees ( [Store#], ShipTo,
CompanyName, AddressOne, AddressTwo, City, St, Zip, StoreCode ) " & _
"SELECT tblReplacementChairOrders.PONumber,
tblReplacementChairOrders.[Customer Name], tblReplacementChairOrders.Company,
tblReplacementChairOrders.AddressOne, tblReplacementChairOrders.AddressTwo,
tblZipCodes.City, tblZipCodes.State, tblReplacementChairOrders.Zip,
tblReplacementChairOrders.StoreCode " & _
"FROM tblReplacementChairOrders INNER JOIN tblZipCodes ON
tblReplacementChairOrders.Zip = tblZipCodes.ZIPCODE " & _
"WHERE
(((tblReplacementChairOrders.PONumber)=[Forms]![frmReplacementChairOrders]![PONumber]));"
DoCmd.RunSQL "INSERT INTO tblPOHeader ( PurchaseOrderNumber,
StoreNumber, Customer, NovimexDate, StoreCode, OrderDate, RequestedShipDate
)" & _
"SELECT tblReplacementChairOrders.PONumber,
tblReplacementChairOrders.PONumber, 'Novimex' AS Company,
tblReplacementChairOrders.Date, tblReplacementChairOrders.StoreCode,
tblReplacementChairOrders.Date, tblReplacementChairOrders.Date " & _
"FROM tblReplacementChairOrders " & _
"WHERE
(((tblReplacementChairOrders.PONumber)=[Forms]![frmReplacementChairOrders]![PONumber]));"
DoCmd.RunSQL "INSERT INTO tblPurchaseOrders ( PurchaseOrderNumber,
ItemNumber, POSerialNumber, CustomerSerialNumberPurchaseOrder,
QuantityOrdered, Whse )" & _
"SELECT tblReplacementChairOrders.PONumber,
tblReplacementChairOrders.[Item#], [PONumber] & (Left([item#],3)) &
(Right([Item#],4)) AS POSerialNumber, 'Novimex' & ([item#]) AS
CustommerSerialNumber, tblReplacementChairOrders.Qty, 'NVMX' AS Whse " & _
"FROM tblReplacementChairOrders " & _
"WHERE
(((tblReplacementChairOrders.PONumber)=[Forms]![frmReplacementChairOrders]![PONumber]));"
DoCmd.SetWarnings True
DoCmd.Close
End If
Nelson said:
I am having a situation where users are entering data that the primary key
should prevent. However instead of stopping the entry, the primary key and
the one to many relationship are being "removed", allowing bad data into the
tables.
Nelson White