Those two processors seat on different sockets, so you might need proper motherboard to support your favourite. In my own opinion, AMD Athlon X4 845 is much better for the following reasons,
Athlon X4 845 is based on the newer microarchitecture, and supports many additional instruction sets which Athlon II X4 lacks, its higher working frequency would also boost some applications focusing the light multitask. And the most important thing is that the PCI-E 3.0 X16 bus logic is integrated onto processor core, providing much higher bandwidth which Athlon II X4 lacks, and the latter would never support PCI-E 3.0. In other words, it supports recent graphics cards at much levels ahead.
2. Power Consumption and Cost
Athlon X4 845 has a TDP of only 65W, but Athlon II X4 640 has a much higher TDP 95W. The higher TDP a processor configured, the more money would be spent onto the heatsink and energy.
Athlon II X4 640 could place on the phased-out platforms such as AM2+, AM3 and AM3+, it supports DDR2 and DDR3 memory modules, but Athlon X4 845 could only placed onto FM2+ socket, only DDR3 memory modules supported. So if you have old machines based on AM2+/AM3/AM3+, it is quite smarter to choose the former. Because this year the newcomer, AMD Ryzen would debut, and its performance is said charming Intel processors too a lot. If you have FM2+, the latter is your smart choice. If you have no such motherboards, I suggest you make some a further plan on your own needs.