When can a child preparing for confirmation be denied confirmation?
Assuming a child is not asking to receive confirmation at an inappropriate/inopportune time and is not prohibited by law (e.g. married outside the church) that would leave only the possibility that the child is not properly disposed to receive the sacrament.
It is the duty of the parish priests to be sure that the child is properly disposed to receive the sacrament of confirmation (canon 843 §2). This is obviously a bit of a judgment call but because Canon Law establishes a right to receive the sacrament the burden does fall on the one denying the sacrament to explain how the child is not properly prepared (canon 18).
A pastor could legitimately question the proper disposition of someone asking for confirmation who fails to regularly attend Mass, explicitly denies the faith, expresses desire not to be confirmed, displays an exaggerated ignorance of the faith, or other similar actions.
A pastor cannot deny the sacrament based solely on lack of service hours, attendance at parish programs or activities, lack of knowledge of the faith beyond the child’s years, occasional lack of Mass attendance, etc.
An occasional failure to attend Mass or total failure to complete reasonable service hours and attend reasonable parish programs might be signs that something is amiss, but in and of themselves are not proper grounds for denying a sacrament.
Religious Education/Faith Formation programs run by a parish cannot be required for the reception of the sacrament of confirmation. A child properly educated by his/her parents in the faith who regularly attends Mass must be permitted to receive the sacrament of confirmation.
Congregation for Divine Worship (protocol No. 2607/98/L; 1999 Notitiae, pages 537-540):
[I]t is also clear that any such complementary legislation must always be interpreted in accord with the general norm of law… Since it has been demonstrated that the [individual in question is properly prepared and not prohibited by law], any other considerations, even those contained in the Diocesan Policy, need to be understood in subordination to the general norms governing the reception of the Sacraments.
Consequently, when a member of the faithful wishes to receive this Sacrament, even though not satisfying one or more elements of the local legislation, these elements must give way to the fundamental right of the faithful to receive the Sacraments.