In this paper, we propose a novel method for control the formation of the autonomous robots following to the desired formations during tracking a moving target under the influence of the dynamic environment. The V-shape formation is used to track a moving target when the distance from this formation to the target is longer than the target approaching radius. Furthermore, when the leader moves in the target approaching range, the circling shape formation is used to encircle the target. The motion of the robots to the optimal positions in the desired formations are controlled by the artificial force fields, which consist of local and global potential fields around the virtual nodes in the desired formations. Using the global attractive force field around the target, the formation of robots is always driven towards the target position. Moreover, using the repulsive/rotational vector fields in the obstacle avoiding controller, robots can easily escape the obstacle without collisions. The success of the proposed method is verified in simulations.