The first problem is you do not have any error trapping, without it you will not necessarily get the correct error message or sometimes none at all.
So add some error trapping so that you can tell us what has gone wrong with the code.