0

In access I have Form name FB (table name = FB) and SubForm name FBB ( table =FBB) (relationship one to many) I use ( currentdb.execute "insert into FBB (FBID, ProductName, Quantity) "& _value (" & me.FBID &",'" & me.ProductName &"','" & me.Quantity &"') What i want now is how if ProductName is a duplicate update the value Quantity by sum with me.Quantity in the same FBID

And thank you in advance

I tried to use on duplicate update the key but doesn't exist in access

  • 1
    Why are you using VBA and SQL INSERT to enter data? Are you not using a bound form for data entry? Saving aggregate data is usually a bad idea. Enter transaction records then calculate sums when needed. – June7 Nov 23 '22 at 08:10
  • what you want to do is an upsert so search using the keywords upsert and msaccess. for instance here: https://stackoverflow.com/questions/6199417/upserting-in-ms-access However, find a more beginner friendly source. The dcount solution is easier and works with vba. finally, your string of sql is malformed. So first address that. one way to debug your sql strings is to assign the whole sqring of sql to a single string then add a (DEBUG.Print thatsinglestring to your code) – mazoula Nov 24 '22 at 05:23

0 Answers0