in the area of the tranny. There should be a speed sending unit (sensor) on the top rear part of the tranny. It is there to tell the ECU/computer exactly what the output shaft is seeing for speed.
The speedometer gets is readings from the sensor located on rear differential, not the tranny. The transmission troubleshooting page on BMWE34.net says that the tranny speed sensor (pulse generator) gets dirty or can go bad, causing the Trans Program. Link below:
http://www.bmwe34.net/e34main/trouble/TransProgram.asp
If a mechanic has checked for thrown codes, then I would give that a shot. The part is about $130 last time I checked,but the tranny has to be lowered to access it.
Check it out.
JD