Plaintiff appeals the dismissal of his action for a declaratory judgment that would permit him to administer therapeutic and nutritional substances by injection. The case is before us for the second time. In Reynolds v. State Board of Naturopathic Exam., 80 Or App 438, 441, 722 P2d 739 (1986) (Reynolds I), we held that, because the complaint presents a justiciable controversy, the court could not dismiss the action for failure to state ultimate facts sufficient to constitute a claim. ORCP 21 A.
On remand, plaintiff filed a third amended complaint. Defendant did not answer it or move for summary judgment or for judgment on the pleadings. It moved to dismiss the complaint on these grounds:
“1. [It] fails to state ultimate facts sufficient to constitute a claim. ORCP 21A(8).
“2. Plaintiff is not the real party in interest in asserting his patients’ interests. ORCP 21A(6).
“3. Plaintiff has failed to join his patients as parties. ORCP 21A(7).
“4. [T]he court lacked subject matter jurisdiction. ORCP 21G(4); ORS 183.410, ORS 183.484.”
The court granted the motion and entered a judgment for defendant that recited that, although “the third Amended Complaint states a justiciable controversy, nonetheless, ORS 685.030(4) is constitutional and, therefore, the plaintiffs claim is dismissed on the merits.”1
Defendant argues that the court must have treated its motion to dismiss as a motion for judgment on the pleadings, which it was not entitled to do. Defendant had not answered. The pleadings were not closed. ORCP 21B. Defendant also urges, as it did in Reynolds I, that we should affirm the court’s *108judgment, because the court reached the correct result, however wrong its route, and any error was harmless. As in Reynolds I, we decline.2
Reversed and remanded.
The court’s statement that ORS 685.030(4) is constitutional does not dispose of all of plaintiffs claims. One of the claims is that, even if ORS 685.030(4) is constitutional, it does not authorize defendant to prohibit plaintiff from injecting nonpoisonous plant substances, water or food.
In Reynolds I, we stated:
“Defendants acknowledge that it is wrong to dismiss a complaint for declaratory relief on the ground that it fails to state a claim, if it alleges a justiciable controversy. They argue, however, that
“ ‘[a]ny error by the trial court was plainly harmless. Even if defendants were not entitled to dismissal, they would be entitled * * * to a judgment on the pleadings * * *. See ORCP 21B.’
“We express no opinion on the merits of this case, because defendants have not yet answered and moved for a judgment on the pleadings.” 80 Or App at 442. (Footnote omitted.)