
79 Ill. App.3d 224 (1979)
398 N.E.2d 236
CYRUS BASS, Plaintiff-Appellant,
v.
WILLIAM J. SCOTT, Attorney General, Defendant-Appellee.
No. 78-1867.
Illinois Appellate Court  First District (5th Division).
Opinion filed November 30, 1979.
*225 Cyrus Bass, of Chicago, for appellant.
William J. Scott, Attorney General, of Chicago (George H. Klumpner, Assistant Attorney General, of counsel), for appellee, pro se.
Judgment affirmed.
Mr. JUSTICE LORENZ delivered the opinion of the court:
Plaintiff appeals from an order of the circuit court dismissing his action for a declaratory judgment against the defendant William J. Scott, Attorney General of the State of Illinois, contending that the dismissal on the basis of res judicata was improper.
In his previous action, Bass v. Stackler, et al., 76 L 11014, plaintiff sought a writ of mandamus to compel the Attorney General to enforce certain provisions of the Illinois Optometric Practice Act (Ill. Rev. Stat. 1977, ch. 111, par. 3801 et seq.). More specifically, he sought the enforcement of the Act's provisions regulating the business relationships and permissible advertisements of an optometrist. (Ill. Rev. Stat. 1977, ch. 111, par. 3827.) That action was dismissed with prejudice by the trial court on September 15, 1976, and plaintiff appealed. On July 26, 1977, he voluntarily dismissed his appeal.
Approximately one year later, on April 26, 1978, he filed this action seeking a declaration of his rights under the Illinois Optometric Practice Act and an order requiring the Attorney General to investigate and enforce the provisions of the Act. The Attorney General moved to dismiss this action on the basis of res judicata, and the trial court granted the motion.

OPINION
 1, 2 Under the doctrine of res judicata, a former adjudication on the merits by a court of competent jurisdiction constitutes an absolute bar to a second adjudication where there is identity of parties, subject matter and cause of action. (Ray Schools-Chicago-Inc. v. Cummins (1957), 12 Ill.2d 376, 146 N.E.2d 42.) The doctrine extends not only to questions actually litigated in former adjudication, but also to matters which could have been decided in that suit. (La Salle National Bank v. County Board of School Trustees (1975), 61 Ill.2d 524, 337 N.E.2d 19, cert. denied (1976), 425 U.S. 936, 48 L.Ed.2d 177, 96 S.Ct. 1668.) Moreover, any error which may have been committed in the first adjudication does not permit the second court to ignore the doctrine of res judicata in an attempt to remedy that error. (People ex rel. McAllister v. East (1951), 409 Ill. 379, 100 N.E.2d 746.) In such a situation, the proper recourse is to attack the first judgment in a direct appeal.
*226  3 In the present case, no question is raised as to whether the first court had jurisdiction; whether the former adjudication was on the merits; or whether the same parties and subject matter are involved in both actions. Plaintiff does contend, however, that this action for declaratory relief presents a separate cause of action from the writ of mandamus requested in the first action. In deciding this question, the test is whether the underlying facts are identical in both actions or whether the same evidence would sustain both actions. (Schultz v. Bank of Lyons (1978), 66 Ill. App.3d 698, 384 N.E.2d 113.) Here, in both actions plaintiff sought to compel the Attorney General to prosecute violators of the Illinois Optometric Practice Act. Thus, in either action, the pivotal question is whether the Act imposes an enforceable duty upon the Attorney General to prosecute violators of the Act. Plaintiff had his opportunity to litigate this issue in the first action. When the trial court dismissed that action, plaintiff's recourse was to attack that ruling on direct appeal. We hold that the trial court properly dismissed this action for a declaratory judgment on the basis of res judicata.
Accordingly, the order of the circuit court is affirmed.
Affirmed.
SULLIVAN, P.J., and MEJDA, J., concur.
