We present a variational approach to the Heisenberg antiferromagnetic model for spin 1/2 and anisotropic exchange, with an external longitudinal and transverse magnetic field. In the one-dimensional case, we calculate exactly with our trial function the expectation values of energy, sublattice magnetization, and magnetic susceptibility. On minimizing the energy, we obtain several phases, which depend on the strength of the field and anisotropy parameter. Subsequently we approach the problem numerically and solve it for a chain of 12 spins using the Lanczos method. The two approaches are in excellent concordance, particularly for the critical fields of the transitions, over a wide range of the parameters of the model. Beside its precision and mathematical simplicity, the method has the important advantage of accounting for the different magnetic phases and their transitions with a single trial function that has a compact mathematical expression. The formalism is expected to work better