Affichage des articles dont le libellé est Key violation. Afficher tous les articles
Affichage des articles dont le libellé est Key violation. Afficher tous les articles

Key violation

jeudi 23 avril 2015

This must be sooo obvious; why can I not find what's going on ?
When I execute the following, I get a key violation error.
Code:

strSQLString = "UPDATE OfferForSale " & _
    "SET OfferForSale.SoldFlag = " & True & _
    ", OfferForSale.fkSalesRecordID = " & SalesRecordID & _
    ", OfferForSale.HighestBid = " & mSold(mintNumberOfItems).SoldFor & _
    " WHERE OfferID = " & lngOfferForSale & ";"
.
.
DoCmd.RunSQL strSQLString

If I remove the SalesRecordID update, the update works :
Code:

strSQLString = "UPDATE OfferForSale " & _
    "SET OfferForSale.SoldFlag = " & True & _
    ", OfferForSale.HighestBid = " & mSold(mintNumberOfItems).SoldFor & _
    " WHERE OfferID = " & lngOfferForSale & ";"
.
.
DoCmd.RunSQL strSQLString

OfferForSale.fkSalesRecordID is a long integer, while SalesRecordID is the primary key of a record newly added to the SalesRecords table. It has been saved by means of Me.Dirty=False and I can check that the new record, with that ID, is indeed in the table before executing this SQL.

Just had a thought - the SalesRecords table is in my front-end while I am testing, whereas the OfferForSale table is on the back-end server. Could that be anything to do with it ?
Key violation

Labels