How can I prevent the system from going back to the first screen of the transaction in case of an error message?

You can use the command "No return on error" in your input script. In this case the system stops the InputScript if an error message occurs, and the user can correct the error and continue with the transaction.