
812 S.W.2d 625 (1991)
Leona HANKS, Appellant,
v.
LAKE TOWNE APARTMENTS, Appellee.
No. 05-90-01291-CV.
Court of Appeals of Texas, Dallas.
June 21, 1991.
Rehearing Denied July 30, 1991.
James B. Pinson, Dallas, for appellant.
J. Hunter Johnson, Dallas, for appellee.
Before ROWE, WHITTINGTON and CHAPMAN, JJ.

OPINION
ROWE, Justice.
Leona Hanks appeals from the dismissal, with prejudice, of her counterclaim against Lake Towne Apartments. We determine that the trial court properly dismissed the counterclaim, but we agree with Hanks's assertion that the counterclaim should not have been dismissed with prejudice to Hanks's right to refile her claim against Lake Towne. Accordingly, we reform the order of dismissal and affirm the order as reformed.
*626 Lake Towne filed an action in a justice of the peace court against Hanks, one of its tenants, alleging forcible detainer and seeking possession of the apartment occupied by Hanks. The justice court granted judgment in Hanks's favor, and Lake Towne appealed to the county court at law, thereby initiating a de novo trial in the county court. Hanks filed a counterclaim in the county court action, alleging that Lake Towne had wrongfully evicted her pursuant to a default judgment obtained against Hanks in a second forcible detainer action without proper notice to Hanks. Hanks also alleged in her counterclaim that Lake Towne had wrongfully retained her security deposit. Lake Towne thereafter moved the county court for dismissal of both its appeal and Hanks's counterclaim. The county court dismissed both the appeal and the counterclaim "with prejudice to the right of the parties to refile same."
In her first three points of error, Hanks contends that the county court erred in dismissing her counterclaim. Both parties agree that the dismissal was based on lack of subject matter jurisdiction, but they disagree as to the existence of such jurisdiction.
Generally, a dismissal or nonsuit at the urging of a plaintiff cannot be used to prejudice the defendant's right to be heard on a pending counterclaim for affirmative relief. PHB, Inc. v. Goldsmith, 534 S.W.2d 196, 198 (Tex.Civ.App.Houston [14th Dist.]), writ ref'd n.r.e. per curiam, 539 S.W.2d 60 (Tex. 1976); Tex.R.Civ.P. 96, 162. On the other hand, when a court lacks jurisdiction of the subject matter of a claim (or counterclaim), it becomes the duty of the court to dismiss the claim. General Tel. Co. v. City of Point Comfort, 553 S.W.2d 808, 811 (Tex.Civ.App.Corpus Christi 1977, no writ).
The primary purpose of a forcible detainer action is resolution of the issue of who is entitled to immediate possession of the premises. Johnson v. Highland Hills Drive Apartments, 552 S.W.2d 493, 495 (Tex.Civ.App.Dallas 1977), writ ref'd n.r.e. per curiam, 568 S.W.2d 661 (Tex. 1978). However, an applicable rule of civil procedure provides that some claims other than the right of possession may be litigated in the county court. The rule states:
On the trial of the cause in the county court the appellant or appellee shall be permitted to plead, prove and recover his damages, if any, suffered for withholding or defending possession of the premises during the pendency of the appeal.
Damages may include but are not limited to loss of rentals during the pendency of the appeal and reasonable attorney fees in the justice and county courts provided, as to attorney fees, that the requirements of Section 24.006 of the Texas Property Code have been met. Only the party prevailing in the county court shall be entitled to recover damages against the adverse party. He shall also be entitled to recover court costs. He shall be entitled to recover against the sureties on the appeal bond in cases where the adverse party has executed such bond.
Tex.R.Civ.P. 752 (emphasis added). The damages recoverable under rule 752 are limited to those expenses and losses related to maintaining or obtaining possession of the premises. Rushing v. Smith, 630 S.W.2d 498, 500 (Tex.App.Amarillo 1982, no writ).
The question in this case is whether a tenant's counterclaim for damages for unlawful retention of the tenant's security deposit and for wrongful eviction pursuant to a second and distinct forcible detainer action constitutes a claim for damages suffered in maintaining or defending possession of the premises during the pendency of the appeal.
One Texas court has held, without analyzing the issue, that a claim alleging unlawful retention of a tenant's security deposit cannot be raised in a forcible detainer action in the county court. Koelzer v. Pizzirani, 718 S.W.2d 420, 424 (Tex.App. Fort Worth 1986, no writ). Although the case relied on by the court does not directly support the holding stated by the court, see Holcomb v. Lorino, 124 Tex. 446, 452, 79 S.W.2d 307, 309 (1935), we determine that the holding is correct.
*627 A claim that a landlord has wrongfully retained a tenant's security deposit, whether the claim is based on statute, see Tex. Prop.Code Ann. § 92.109 (Vernon 1984), or on contract, is not closely related to the losses or expenses incurred by the tenant in defending possession of the premises during the pendency of the appeal. We acknowledge that the claim, like the issue regarding the right of possession, arises out of the tenant-landlord relationship. In that sense, the two issues are related, but we fail to see how damages accruing from retention of the deposit constitute a loss or expense resulting from defense of the right of possession. Nor has Hanks provided an adequate explanation of her assertion that such damages are "ancillary to her defense of possession of the premises." It may well be that the damages were suffered during the pendency of the appeal, but that alone is not enough. In the language of the rule, the damages must have been "suffered for ... defending possession of the premises." Tex.R.Civ.P. 752.
The action of forcible detainer was created by the legislature to provide a speedy, simple, and inexpensive means for resolving the question of the right of possession of premises. Holcomb, 124 Tex. at 452, 79 S.W.2d at 309; Johnson v. Fellowship Baptist Church, 627 S.W.2d 203, 204 (Tex. App.Corpus Christi 1981, no writ); see Tex.Prop.Code Ann. §§ 24.001-24.011 (Vernon Supp.1991). In our view, confining the damages that may be sought to those suffered as a direct result of withholding or defending possession promotes this legislative purpose. If other more remotely related claims arising out of the tenant-landlord relationship could be asserted in the county court, the forcible detainer proceedings would almost certainly be less speedy, more complex, and more expensive. Accordingly, we hold that Hanks's damages, if any, accruing from the alleged wrongful retention of her security deposit were not suffered in maintaining or defending possession of the premises. The county court properly dismissed Hanks's claim for those damages because the court's jurisdiction over the appeal did not extend to the subject matter of the claim.[1]
As to Hanks's claim for damages for alleged wrongful eviction, we reach the same result.
In a 1941 case decided by the Texas Supreme Court, Tallwater v. Brodnax, 137 Tex. 604, 156 S.W.2d 142 (1941), a landlord filed a forcible detainer suit against two tenants. The justice court rendered judgment for the tenants, and the landlord appealed to the county court at law. While the appeal was pending, the landlord procured an order for a writ of possession after filing a bond in the justice court. The landlord evicted the tenants pursuant to the writ of possession. After the eviction, the appeal to the county court resulted in a final judgment in favor of the tenants.
The tenants thereafter filed a separate lawsuit in the county court at law alleging wrongful eviction. They sought damages suffered because of the eviction and attorney fees incurred in defending the previous forcible detainer suit. The county court dismissed this cause, and the tenants appealed to the court of civil appeals. The court of civil appeals submitted two certified questions to the Texas Supreme Court. The first question inquired whether the tenant's claims involved damages recoverable in a forcible detainer action under former article 3990, the statutory predecessor to rule 752. The second question asked, "Is it mandatory under the statute that the injured party assert such damages on the trial of the detainer suit in the county court, the same being within the jurisdiction of such court and arising during the pendency of the statutory proceedings?"
At the time, article 3990 provided:
*628 On the trial of the cause in the county court the appellee shall be permitted to prove the damages for withholding the possession of the premises from the appellee during the pendency of the appeal and the reasonable expenses of the appellee in prosecuting or defending the cause in the county court; and, if the possession of the premises be not adjudged to the appellant, said court shall render judgment also in favor of the appellee and against said appellant and the sureties on his bond for the damages proven and all costs.
Act of Feb. 21,1927, 40th Leg., R.S., ch. 51, § 1,1927 Tex.Gen.Laws 74, 75, repealed by Act of May 15,1939, 46th Leg., R.S., ch. 25, § 1, 1939 Tex.Gen.Laws 201; see Tallwater, 137 Tex. at 607, 156 S.W.2d at 143. Aside from the fact that it limited recovery to a prevailing appellee, the prior statute contained language which was in substance similar to the pertinent language of the present rule 752.[2] The Tallwater court also referred to former article 3994, which stated, "The proceedings under a forcible entry, or forcible detainer, shall not bar an action for trespass, damages, waste, rent or mesne profits." Tex.Rev.Civ.Stat.Ann. art. 3994 (Vernon 1966), repealed by Act of June 19, 1983, 68th Leg., R.S., ch. 576, § 6, 1983 Tex.Gen.Laws 3475, 3729-30 (current version at Tex.Pbop.Code Ann. § 24.008 (Vernon Supp.1991)).
With respect to the claim for attorney fees incurred in defending the forcible detainer suit, the Texas Supreme Court held that article 3990 provided the exclusive remedy for recovery of such fees and that the fees could not be sought in a suit independent of the forcible detainer action. Tallwater, 137 Tex. at 607-08, 156 S.W.2d at 144. As to the claim for damages resulting from the alleged wrongful eviction, the court held that the right of action emanated from the common law and the claim could be litigated in the tenants' independent suit. The court further stated that "the provisions of Article 3994, if needed for the purpose, are available to supply legal justification for the failure of the [tenants] to urge these items of damage in the forcible ... detainer suit." Id., 137 Tex. at 608, 156 S.W.2d at 144.
Hanks suggests that the supreme court held that a claim for damages for wrongful eviction could be asserted either in an independent lawsuit or in the forcible detainer proceeding. We acknowledge that the court used language that provides an arguable basis for Hanks's contention, but we determine that the court's holding was not so broad. By simply holding that the claim of wrongful eviction could be asserted in the suit filed after the previous forcible detainer action, the court answered the question before it. The court did not need to determine, and it did not determine, whether the claim could have been asserted in the prior forcible detainer action. It merely stated that, if legal justification was needed for failing to assert the claim in the prior action, article 3994 provided the justification. The court did not say that such justification was required. Although the court may have assumed, for purposes of its analysis, that the wrongful eviction claim could have been raised in the forcible detainer action, it did not so decide.
In any event, the claim for wrongful eviction in this case does not arise out of the present forcible detainer action; instead, it arises out of a second forcible detainer action filed by Lake Towne. The record of this second action is not before us, nor does the appellate record indicate that the county court had access to the record associated with the second action. With respect to the second forcible detainer proceeding, our record contains only the allegations in Hanks's counterclaim. Under these particular circumstances, we hold that any damages suffered as a result of the second forcible detainer action and any resulting wrongful eviction were not recoverable in the present proceeding. Whatever *629 the scope of the damages recoverable under rule 752, we cannot accept the argument that the rule contemplates recovery, in one forcible detainer action, of damages associated with a second forcible detainer action. Hanks's argument cannot be reconciled with the legislative purpose of providing a speedy, simple, and inexpensive remedy for determining the right to immediate possession of premises.
The county court did not have subject matter jurisdiction over Hanks's claim of wrongful eviction arising out of the second forcible detainer action, and the court correctly dismissed the counterclaim.[3] We overrule the first three points of error.
In the last three points of error, Hanks argues that the county court erred in dismissing her counterclaim "with prejudice" to her right to refile the claim. Lake Towne concedes the validity of these points of error. We agree. The forcible detainer action is cumulative of other remedies that a party may have. Holcomb, 124 Tex. at 452, 79 S.W.2d at 309; Johnson, 552 S.W.2d at 495; see Tex.Prop.Code Ann. § 24.008 (Vernon Supp.1991). We sustain points of error four through six.
We reform the order of dismissal so that Hanks's counterclaim is dismissed without prejudice to her right to pursue the claims contained therein. As reformed, we affirm the order of dismissal.
NOTES
[1]  Hanks's only claim for attorney fees was based on the statutory provision authorizing recovery of such fees (in addition to statutory penalties) because of bad faith retention of a security deposit. Tex.Prop.Code Ann. § 92.109(a) (Vernon 1984). Since the statute authorizes recovery of such fees "in a suit to recover the deposit" and since Hanks cannot pursue in the county court her claim for the deposit, she also cannot pursue in that court her claim for the fees.
[2]  Because former article 3990 authorized recovery of damages for withholding possession of the premises but did not specifically provide for recovery of damages for defending possession (although it did allow recovery of expenses incurred in prosecuting or defending the cause in the county court), the legislature may have assumed that the appellee would typically be the landlord.
[3]  We do not decide whether a claim for damages for an allegedly wrognful eviction resulting from the instatn forcible detainer proceeding (as opposed to a second and distrnct forcible detainer action) could be asserted in the county court under rule 752. See Tallwater, 137 Tex. at 605-08, 156 S.W.2d at 142-44; Bums v. Johnson, 491 S.W.2d 692, 692-94 (Tex.Civ.App.Waco 1973, writ ref'd n.r.e.).
