When does a resistor affect current and voltage?
The voltage was constant because the power supply maintained the voltage (that's its job). In a similar way, if you make a constant current source and pass that current through a variable resistor, then varying the resistance value will change the voltage while the current remains the same.