D
Don Johnson
I have a macro in Access 2007 that executes some VBA code which creates a
number of tables and then runs a series of append and update queries to
append records to ODBC linked SQL files.
When the append queries listed below is executed by the macro, I get a key
violations message, "Microsoft Office Access can't append all of the records
in the append query. Microsoft Office Access set 0 field(s) to Null due to a
type conversion failure, and it didn't add 2 record(s) to the table due to
key violations, 0 record(s) due to lock violations, and 0 record(s) due to
validation rule violations. Do you want to run the action query anyway? To
ignore the error(s) and run the query, click Yes. For an explanation of the
causes of the violations, click Help."
I am trying to add two records at this point. Clicking yes does not add
them. Clicking on the Help button simply gets me to a generic Access Help
window with no specific link to my problem.
Yet, if I run the the append query by itself, rather than through the macro,
I do not get a key violation and the records are added.
I suspect the key violations relate to stored procedures in the SQL file
concerning how the date and time fields are stored. I cannot understand if I
have solved these so that the append query will execute properly by itself,
why it should thwen have a problem when run in a macro.
The append query is SQL view is as follows:
INSERT INTO dbo_IV00102 ( ITEMNMBR, LOCNCODE, BINNMBR, RCRDTYPE, PRIMVNDR,
ITMFRFLG, BGNGQTY, LSORDQTY, LRCPTQTY, LSTORDDT, LSORDVND, LSRCPTDT,
QTYRQSTN, QTYONORD, QTYBKORD, QTY_Drop_Shipped, QTYINUSE, QTYINSVC, QTYRTRND,
QTYDMGED, QTYONHND, ATYALLOC, QTYCOMTD, QTYSOLD, NXTCNTDT, NXTCNTTM,
LSTCNTDT, LSTCNTTM, STCKCNTINTRVL, Landed_Cost_Group_ID, BUYERID, PLANNERID,
ORDERPOLICY, FXDORDRQTY, ORDRPNTQTY, NMBROFDYS, MNMMORDRQTY, MXMMORDRQTY,
ORDERMULTIPLE, REPLENISHMENTMETHOD, SHRINKAGEFACTOR, PRCHSNGLDTM,
MNFCTRNGFXDLDTM, MNFCTRNGVRBLLDTM, STAGINGLDTME, PLNNNGTMFNCDYS,
DMNDTMFNCPRDS, INCLDDINPLNNNG, CALCULATEATP, AUTOCHKATP, PLNFNLPAB,
FRCSTCNSMPTNPRD, ORDRUPTOLVL, SFTYSTCKQTY, REORDERVARIANCE, PORECEIPTBIN,
PORETRNBIN, SOFULFILLMENTBIN, SORETURNBIN, BOMRCPTBIN, MATERIALISSUEBIN,
MORECEIPTBIN, REPAIRISSUESBIN, ReplenishmentLevel, POPOrderMethod,
MasterLocationCode, POPVendorSelection, POPPricingSelection, PurchasePrice,
IncludeAllocations, IncludeBackorders, IncludeRequisitions,
PICKTICKETITEMOPT, INCLDMRPMOVEIN, INCLDMRPMOVEOUT, INCLDMRPCANCEL,
DEX_ROW_ID )
SELECT tblItemQuantityMstr.ITEMNMBR, tblItemQuantityMstr.LOCNCODE,
tblItemQuantityMstr.BINNMBR, tblItemQuantityMstr.RCRDTYPE,
tblItemQuantityMstr.PRIMVNDR, tblItemQuantityMstr.ITMFRFLG,
tblItemQuantityMstr.BGNGQTY, tblItemQuantityMstr.LSORDQTY,
tblItemQuantityMstr.LRCPTQTY, tblItemQuantityMstr.LSTORDDT,
tblItemQuantityMstr.LSORDVND, tblItemQuantityMstr.LSRCPTDT,
tblItemQuantityMstr.QTYRQSTN, tblItemQuantityMstr.QTYONORD,
tblItemQuantityMstr.QTYBKORD, tblItemQuantityMstr.QTY_Drop_Shipped,
tblItemQuantityMstr.QTYINUSE, tblItemQuantityMstr.QTYINSVC,
tblItemQuantityMstr.QTYRTRND, tblItemQuantityMstr.QTYDMGED,
tblItemQuantityMstr.QTYONHND, tblItemQuantityMstr.ATYALLOC,
tblItemQuantityMstr.QTYCOMTD, tblItemQuantityMstr.QTYSOLD,
tblItemQuantityMstr.NXTCNTDT, tblItemQuantityMstr.NXTCNTTM,
tblItemQuantityMstr.LSTCNTDT, tblItemQuantityMstr.LSTCNTTM,
tblItemQuantityMstr.STCKCNTINTRVL, tblItemQuantityMstr.Landed_Cost_Group_ID,
tblItemQuantityMstr.BUYERID, tblItemQuantityMstr.PLANNERID,
tblItemQuantityMstr.ORDERPOLICY, tblItemQuantityMstr.FXDORDRQTY,
tblItemQuantityMstr.ORDRPNTQTY, tblItemQuantityMstr.NMBROFDYS,
tblItemQuantityMstr.MNMMORDRQTY, tblItemQuantityMstr.MXMMORDRQTY,
tblItemQuantityMstr.ORDERMULTIPLE, tblItemQuantityMstr.REPLENISHMENTMETHOD,
tblItemQuantityMstr.SHRINKAGEFACTOR, tblItemQuantityMstr.PRCHSNGLDTM,
tblItemQuantityMstr.MNFCTRNGFXDLDTM, tblItemQuantityMstr.MNFCTRNGVRBLLDTM,
tblItemQuantityMstr.STAGINGLDTME, tblItemQuantityMstr.PLNNNGTMFNCDYS,
tblItemQuantityMstr.DMNDTMFNCPRDS, tblItemQuantityMstr.INCLDDINPLNNNG,
tblItemQuantityMstr.CALCULATEATP, tblItemQuantityMstr.AUTOCHKATP,
tblItemQuantityMstr.PLNFNLPAB, tblItemQuantityMstr.FRCSTCNSMPTNPRD,
tblItemQuantityMstr.ORDRUPTOLVL, tblItemQuantityMstr.SFTYSTCKQTY,
tblItemQuantityMstr.REORDERVARIANCE, tblItemQuantityMstr.PORECEIPTBIN,
tblItemQuantityMstr.PORETRNBIN, tblItemQuantityMstr.SOFULFILLMENTBIN,
tblItemQuantityMstr.SORETURNBIN, tblItemQuantityMstr.BOMRCPTBIN,
tblItemQuantityMstr.MATERIALISSUEBIN, tblItemQuantityMstr.MORECEIPTBIN,
tblItemQuantityMstr.REPAIRISSUESBIN, tblItemQuantityMstr.ReplenishmentLevel,
tblItemQuantityMstr.POPOrderMethod, tblItemQuantityMstr.MasterLocationCode,
tblItemQuantityMstr.POPVendorSelection,
tblItemQuantityMstr.POPPricingSelection, tblItemQuantityMstr.PurchasePrice,
tblItemQuantityMstr.IncludeAllocations,
tblItemQuantityMstr.IncludeBackorders,
tblItemQuantityMstr.IncludeRequisitions,
tblItemQuantityMstr.PICKTICKETITEMOPT, tblItemQuantityMstr.INCLDMRPMOVEIN,
tblItemQuantityMstr.INCLDMRPMOVEOUT, tblItemQuantityMstr.INCLDMRPCANCEL,
tblItemQuantityMstr.DEX_ROW_ID
FROM tblItemQuantityMstr;
Any thoughts as to how I can get this append query to run in the macro?
number of tables and then runs a series of append and update queries to
append records to ODBC linked SQL files.
When the append queries listed below is executed by the macro, I get a key
violations message, "Microsoft Office Access can't append all of the records
in the append query. Microsoft Office Access set 0 field(s) to Null due to a
type conversion failure, and it didn't add 2 record(s) to the table due to
key violations, 0 record(s) due to lock violations, and 0 record(s) due to
validation rule violations. Do you want to run the action query anyway? To
ignore the error(s) and run the query, click Yes. For an explanation of the
causes of the violations, click Help."
I am trying to add two records at this point. Clicking yes does not add
them. Clicking on the Help button simply gets me to a generic Access Help
window with no specific link to my problem.
Yet, if I run the the append query by itself, rather than through the macro,
I do not get a key violation and the records are added.
I suspect the key violations relate to stored procedures in the SQL file
concerning how the date and time fields are stored. I cannot understand if I
have solved these so that the append query will execute properly by itself,
why it should thwen have a problem when run in a macro.
The append query is SQL view is as follows:
INSERT INTO dbo_IV00102 ( ITEMNMBR, LOCNCODE, BINNMBR, RCRDTYPE, PRIMVNDR,
ITMFRFLG, BGNGQTY, LSORDQTY, LRCPTQTY, LSTORDDT, LSORDVND, LSRCPTDT,
QTYRQSTN, QTYONORD, QTYBKORD, QTY_Drop_Shipped, QTYINUSE, QTYINSVC, QTYRTRND,
QTYDMGED, QTYONHND, ATYALLOC, QTYCOMTD, QTYSOLD, NXTCNTDT, NXTCNTTM,
LSTCNTDT, LSTCNTTM, STCKCNTINTRVL, Landed_Cost_Group_ID, BUYERID, PLANNERID,
ORDERPOLICY, FXDORDRQTY, ORDRPNTQTY, NMBROFDYS, MNMMORDRQTY, MXMMORDRQTY,
ORDERMULTIPLE, REPLENISHMENTMETHOD, SHRINKAGEFACTOR, PRCHSNGLDTM,
MNFCTRNGFXDLDTM, MNFCTRNGVRBLLDTM, STAGINGLDTME, PLNNNGTMFNCDYS,
DMNDTMFNCPRDS, INCLDDINPLNNNG, CALCULATEATP, AUTOCHKATP, PLNFNLPAB,
FRCSTCNSMPTNPRD, ORDRUPTOLVL, SFTYSTCKQTY, REORDERVARIANCE, PORECEIPTBIN,
PORETRNBIN, SOFULFILLMENTBIN, SORETURNBIN, BOMRCPTBIN, MATERIALISSUEBIN,
MORECEIPTBIN, REPAIRISSUESBIN, ReplenishmentLevel, POPOrderMethod,
MasterLocationCode, POPVendorSelection, POPPricingSelection, PurchasePrice,
IncludeAllocations, IncludeBackorders, IncludeRequisitions,
PICKTICKETITEMOPT, INCLDMRPMOVEIN, INCLDMRPMOVEOUT, INCLDMRPCANCEL,
DEX_ROW_ID )
SELECT tblItemQuantityMstr.ITEMNMBR, tblItemQuantityMstr.LOCNCODE,
tblItemQuantityMstr.BINNMBR, tblItemQuantityMstr.RCRDTYPE,
tblItemQuantityMstr.PRIMVNDR, tblItemQuantityMstr.ITMFRFLG,
tblItemQuantityMstr.BGNGQTY, tblItemQuantityMstr.LSORDQTY,
tblItemQuantityMstr.LRCPTQTY, tblItemQuantityMstr.LSTORDDT,
tblItemQuantityMstr.LSORDVND, tblItemQuantityMstr.LSRCPTDT,
tblItemQuantityMstr.QTYRQSTN, tblItemQuantityMstr.QTYONORD,
tblItemQuantityMstr.QTYBKORD, tblItemQuantityMstr.QTY_Drop_Shipped,
tblItemQuantityMstr.QTYINUSE, tblItemQuantityMstr.QTYINSVC,
tblItemQuantityMstr.QTYRTRND, tblItemQuantityMstr.QTYDMGED,
tblItemQuantityMstr.QTYONHND, tblItemQuantityMstr.ATYALLOC,
tblItemQuantityMstr.QTYCOMTD, tblItemQuantityMstr.QTYSOLD,
tblItemQuantityMstr.NXTCNTDT, tblItemQuantityMstr.NXTCNTTM,
tblItemQuantityMstr.LSTCNTDT, tblItemQuantityMstr.LSTCNTTM,
tblItemQuantityMstr.STCKCNTINTRVL, tblItemQuantityMstr.Landed_Cost_Group_ID,
tblItemQuantityMstr.BUYERID, tblItemQuantityMstr.PLANNERID,
tblItemQuantityMstr.ORDERPOLICY, tblItemQuantityMstr.FXDORDRQTY,
tblItemQuantityMstr.ORDRPNTQTY, tblItemQuantityMstr.NMBROFDYS,
tblItemQuantityMstr.MNMMORDRQTY, tblItemQuantityMstr.MXMMORDRQTY,
tblItemQuantityMstr.ORDERMULTIPLE, tblItemQuantityMstr.REPLENISHMENTMETHOD,
tblItemQuantityMstr.SHRINKAGEFACTOR, tblItemQuantityMstr.PRCHSNGLDTM,
tblItemQuantityMstr.MNFCTRNGFXDLDTM, tblItemQuantityMstr.MNFCTRNGVRBLLDTM,
tblItemQuantityMstr.STAGINGLDTME, tblItemQuantityMstr.PLNNNGTMFNCDYS,
tblItemQuantityMstr.DMNDTMFNCPRDS, tblItemQuantityMstr.INCLDDINPLNNNG,
tblItemQuantityMstr.CALCULATEATP, tblItemQuantityMstr.AUTOCHKATP,
tblItemQuantityMstr.PLNFNLPAB, tblItemQuantityMstr.FRCSTCNSMPTNPRD,
tblItemQuantityMstr.ORDRUPTOLVL, tblItemQuantityMstr.SFTYSTCKQTY,
tblItemQuantityMstr.REORDERVARIANCE, tblItemQuantityMstr.PORECEIPTBIN,
tblItemQuantityMstr.PORETRNBIN, tblItemQuantityMstr.SOFULFILLMENTBIN,
tblItemQuantityMstr.SORETURNBIN, tblItemQuantityMstr.BOMRCPTBIN,
tblItemQuantityMstr.MATERIALISSUEBIN, tblItemQuantityMstr.MORECEIPTBIN,
tblItemQuantityMstr.REPAIRISSUESBIN, tblItemQuantityMstr.ReplenishmentLevel,
tblItemQuantityMstr.POPOrderMethod, tblItemQuantityMstr.MasterLocationCode,
tblItemQuantityMstr.POPVendorSelection,
tblItemQuantityMstr.POPPricingSelection, tblItemQuantityMstr.PurchasePrice,
tblItemQuantityMstr.IncludeAllocations,
tblItemQuantityMstr.IncludeBackorders,
tblItemQuantityMstr.IncludeRequisitions,
tblItemQuantityMstr.PICKTICKETITEMOPT, tblItemQuantityMstr.INCLDMRPMOVEIN,
tblItemQuantityMstr.INCLDMRPMOVEOUT, tblItemQuantityMstr.INCLDMRPCANCEL,
tblItemQuantityMstr.DEX_ROW_ID
FROM tblItemQuantityMstr;
Any thoughts as to how I can get this append query to run in the macro?