It's a function because it is triggered by a KixForm button, also will be used in many locations with differeng servers and datases, hence the reason for the var strings etc, I have now also spotted the code tag

I will gather the returned values from the DB functions and post tomorrow.

Thanks