1 (edited by v_pozidis 2020-02-02 20:40:27)

Topic: Adding new quantity

I have a simple database with the partnumber and the quantity of some products. When I insert  an excel file which contains new records (partnumber and qty) and existing partnumber with quantity in a tablegrid  how can the new qty added in the existing qty of the partnumber.  Example when a new order arrives so it adds the new ordered qty in the database. A simply example would help. It has been a week that I can not find the solution so please your help.

Re: Adding new quantity

How are you importing the Excel file? Is it via csv or reading the Excel worksheet directly through the OLE object? Can you attach your project?

Re: Adding new quantity

Please see the picture https://ibb.co/WncwG2F

In my example in the 1 picture you see the part numbers and quantity
in the second picture you choose the file that contains the order
The 3 part number is the result of importing the csv file.
What I wanna do is what you see in the 4 picture.
How to plus the quantity in one raw when the partnumber exist.

Thank you in advance

Post's attachments

Attachment icon TestFile.zip 425.85 kb, 243 downloads since 2020-02-04 

4 (edited by derek 2020-02-04 10:11:33)

Re: Adding new quantity

Hi V_Pozidis, Hi EHW,
Try replacing  'sqlexecute('insert.....'  with 'sqlexecute('update....' in your script.   Please see attached.
Regards,
Derek.

Post's attachments

Attachment icon TestFile.zip 427.91 kb, 259 downloads since 2020-02-04 

Re: Adding new quantity

It works only when it founds same part numbers but in case there are new part numbers it ignores them and doesn't include them to the tablegrid
How to solve that ?

Re: Adding new quantity

V_Pozidis, Derek,
Revised project is attached. I added the logic to check for the existence of a part number. If it does not exist then the part is inserted into the Part table. If it does exist then the qty in the csv file is added to the qty in the Part table.

Post's attachments

Attachment icon TestFile_Revised.zip 427.92 kb, 265 downloads since 2020-02-04 

Re: Adding new quantity

Thank you so much for your big help.

Re: Adding new quantity

Hi today testing it it crashes when it founds new partnumbers.
https://i.ibb.co/0yCb2gQ/test1.jpg

Re: Adding new quantity

Hi Pozidis, EHW,
Try the attached; 
I've tested it with an input file of all new parts, no new parts, mix of new and existing parts, multiples of the same part in the input file etc and it seems fine.
Derek.

Post's attachments

Attachment icon TestFile.zip 338.59 kb, 311 downloads since 2020-02-05 

Re: Adding new quantity

Ahhh….alphanumeric part number. Given the csv test file from v_pozidis, the assumption was that part numbers are numeric. Well as developers we all know what assumptions can do to us. LOL.

Re: Adding new quantity

LOL!