Opinion
COLEMAN, J.Charles D. Fraser was convicted of driving while intoxicated in violation of Code § 18.2-266 and was punished therefor as provided by Code § 18.2-270 (penalty statute) for a second offense committed within less than five years. Fraser contends that the trial court could not punish him as a second offender because his first DWI conviction was void because it was under Fairfax County Code § 82-4-17, which was held to be invalid in Commonwealth v. Knott, 11 Va. App. 44, 47, 396 S.E.2d 148, 150 (1990), and Commonwealth v. Holtz, 12 Va. App. 1151, 1152, 408 S.E.2d 561, 562 (1991). We hold that Fraser’s challenge of his DWI conviction for a first offense under the Fairfax ordinance constitutes an impermissible collateral attack in a prosecution for a second DWI offense under Code §§ 18.2-266 and 18.2-270. Accordingly, we affirm Fraser’s conviction of DWI, second offense, under Code §§ 18.2-266 and 18.2-270.
On December 29, 1987, Fraser was convicted of DWI as a first offense under Fairfax County Code §§ 82-4-17 (offense provision) and 82-4-21 (penalty provision). Subsequent to Fraser’s conviction, we held that the penalty provision for second offenders under Fairfax County Code § 82-4-21 was invalid and that a conviction for a second offense under Fairfax County Code § 82-4-17 could not be used as a predicate to an habitual offender adjudication. Id.
On August 4, 1990, Fraser was arrested and charged with driving while intoxicated in violation of Virginia Code § 18.2-266. At trial, the Commonwealth moved to amend the warrant to charge Fraser with DWI as a second offense within five years so that the enhanced penalty provision under Code § 18.2-270 could be applied. Fraser objected to the amendment, arguing that his 1987 conviction for violating the Fairfax County Code could not be used as a predicate for a second offense under Code § 18.2-270 because the ordinance on which the first conviction was based had been declared invalid in Knott and Holtz.
*777The trial judge ruled that, although he believed Fraser’s first DWI conviction to be invalid, Fraser was precluded from collaterally attacking its validity because the defect in Fairfax County Code § 82-4-21 rendered the conviction voidable and not void. Accordingly, the trial court found Fraser guilty of DWI as a second offender under Code §§ 18.2-266 and 18.2-270.
“A ‘[collateral attack is allowed only where the judgment is void, a void judgment being a judgment rendered without jurisdiction.’ ” Holtz, 12 Va. App. at 1154, 408 S.E.2d at 563 (Coleman, J., dissenting) (quoting State v. Kamalski, 429 A.2d 1315, 1320 (Del. Super. Ct. 1981)). See also Slaughter v. Commonwealth, 222 Va. 787, 793, 284 S.E.2d 824, 827 (1981). A court lacks jurisdiction to enter a criminal judgment if the judgment is predicated upon an unconstitutional or otherwise invalid statute or ordinance. See Annotation, Validity and Effect of Judgment Based upon Erroneous View as to Constitutionality or Validity of a Statute or Ordinance Going to the Merits, 167 A.L.R. 517, 519-20 (1947).
In Knott and Holtz, we held that the penalty provision for a second DWI offense in Fairfax County Code § 82-4-21 was invalid because it did not provide a punishment that was equal to or greater than the punishment provided by the general law in Virginia, as is required under Code § 15.1-132. Holtz, 12 Va. App. at 1152, 408 S.E.2d at 562; Knott, 11 Va. App. at 47, 396 S.E.2d at 150. Accordingly, neither Knott’s nor Holtz’s DWI convictions as second offenders under the Fairfax ordinance could be used as a predicate offense to an habitual offender adjudication. Id.
Fraser misconstrues our holding in the Knott and Holtz cases as invalidating Fairfax County Code §§ 82-4-17 and 82-4-21 entirely and for all purposes. To the contrary, we held that Fairfax County Code § 82-4-21, the penalty provision, was invalid only to the extent of its enhanced penalty provision for second offenders. The substantive provision of Fairfax County Code § 82-4-17 and the first offender penalty provision of Fairfax County Code § 82-4-21 remain valid. See Sos v. Commonwealth, 14 Va. App. 862, 864-65, 867, 419 S.E.2d 426, 427, 429 (1992). In Sos, we held that invalid portions of a statute may be severed and ignored “if the remaining valid portions of the act are sufficient to accomplish their purpose in accordance with the legislative intent.” Id. at 865, 419 S.E.2d at 427. We also held that a party cannot challenge that portion of a statute that does not affect him. Id. at 865, 419 S.E.2d at 428. Therefore, because Fraser was convicted for *778DWI under Fairfax County Code § 82-4-17 and punished as a first offender under Fairfax County Code § 82-4-21, he does not come within the purview of the portion of Fairfax County Code § 82-4-21 that was declared invalid in Knott and Holtz. See id. (defendant, who was convicted under valid portion of statute as a first offender, could not challenge the invalid portion of the statute relating to second offenders). Having made no claim that Fairfax County Code §§ 82-4-17 and 82-4-21 are otherwise invalid as applied to him, Fraser’s challenge of this conviction under the Fairfax ordinance constitutes an impermissible collateral attack.
Affirmed.
Moon, C.J.,* and Willis, X, concurred.
On May 1,1993, Judge Moon succeeded Judge Koontz as Chief Judge.