
675 P.2d 25 (1983)
106 Idaho 46
BARR DEVELOPMENT, INC., a Utah Corporation, Plaintiff-Respondent,
v.
UTAH MORTGAGE LOAN CORP., a Utah corporation, Defendant-Appellant.
No. 14528.
Supreme Court of Idaho.
December 2, 1983.
Rehearing Denied February 14, 1984.
W. Joe Anderson, of Sharp, Anderson, Bush & Nelson, Idaho Falls, for defendant-appellant.
George C. Petersen, Jr., of Petersen, Moss & Olson, Idaho Falls, F.S. Prince, Jr., Salt Lake City, Utah, for plaintiff-respondent.
DONALDSON, Chief Justice.
In December of 1975, Utah Mortgage Loan Corp., the defendant-appellant, granted a $184,000.00 loan at ten percent (10%) to the Havenhurst Corporation. As security for the loan, Havenhurst granted a Deed of Trust to property located in Bonneville County, Idaho. The Deed of Trust restricted the trustor's ability to alienate the property by stating that the entire loan balance would be due upon alienation.
*26 In 1977 Barr Development, the plaintiff-respondent, conducted business transactions with the Havenhurst Corporation resulting in obligations being owed to Barr Development by the Havenhurst Corporation. As security for these loans Havenhurst executed four separate mortgages on the same property in favor of Barr Development. The mortgages to Barr Development were junior to the encumbrance in favor of Utah Mortgage.
Havenhurst subsequently defaulted on these obligations and in 1979 Barr Development foreclosed on its mortgages and received a judgment for $103,578.67. A Decree of Foreclosure and Order of Sale were entered and the property was sold to Barr Development after it bid the amount of its judgment against Havenhurst. After the redemption period expired, title was conveyed to Barr Development.
Utah Mortgage claimed that Havenhurst breached its trust deed by allowing the property to go to execution sale and to be sold. Based upon this alleged default, Utah Mortgage attempted to invoke the due-on-sale clause in the trust deed and refused to accept the installment payments on the underlying note from the plaintiff. Prior to this law suit, Utah Mortgage scheduled a sale of the property by the trustee, but the trial court issued a temporary injunction and subsequently held that Utah Mortgage could not enforce its due-on-sale clause under the circumstances of this case because enforcement of the due-on-sale clause would constitute an unreasonable restraint on the alienation of the property and would be against public policy in the absence of showing an impairment of security. From this determination Utah Mortgage appealed.
Considering the issue of whether or not a due-on-sale clause constitutes an unreasonable restraint on alienation, this Court stated in Lake v. Equitable Savings and Loan Association, 105 Idaho 923, 674 P.2d 419 (1983), that due-on-sale clauses do not affect the title or conveyance of the title, and therefore, are not restraints on alienation.
The trial court also stated that under the circumstances of this case enforcement of the restraint would be against public policy. This Court stated in Lake that the due-on-sale clause in that case was not against public policy. In this case, instead of a voluntary transfer, Barr Development obtained the property through a foreclosure sale. However, we decline to distinguish the two types of transactions and hold that following the rationale set forth in Lake this clause, is also not against public policy. Even though, as stated by the trial court in his memorandum decision, the clause might be against public policy under certain circumstances we decline to strike down the clause set forth in the contract based on circumstances not present in this case.
However, even though the trial court incorrectly determined that the due-on-sale clause was unenforceable because it was an unreasonable restraint on alienation and against public policy, where a judgment of the lower court is correct but based upon an erroneous theory, the judgment will be affirmed upon the correct theory. Duthie v. Lewiston Gun Club, 104 Idaho 751, 663 P.2d 287 (1983); Foremost Insurance Co. v. Putzier, 102 Idaho 138, 627 P.2d 317 (1981). Barr Development argued on appeal that the due-on-sale clause did not apply in this particular situation because the contract in question does not prohibit involuntary transfers. We agree.
Determining the meaning and legal affect of a contract is a question of law. International Engineering Co. v. Daum Industries, Inc., 102 Idaho 363, 630 P.2d 155 (1981). Section B(6) of the contract states: "All sums secured hereby shall become due and payable forthwith at the option of the Beneficiary if the Grantor shall convey away said premises or if the title thereto shall become vested in any other person in any manner whatsoever." Section B(13) states: "Should the property described herein, or any portion thereof, be sold or conveyed or become the subject of any agreement to sell prior to maturity *27 hereof, the entire indebtedness shall immediately become due and payable at the option of the Beneficiary." This Court has stated that special provisions in a contract will control over general provisions where both of the provisions relate to the same thing. Morgan v. Firestone Tire & Rubber Co., 68 Idaho 506, 201 P.2d 976 (1948). Section B(6) is a general provision that states all sums will become due if the title becomes vested in any other person in any manner whatsoever. However, section B(13) is more specific in that it only prohibits a "sale," "conveyance" or "agreement to sell." Because section B(13) is more specific it controls, Morgan, supra, and an examination of this clause indicates that the parties intended the due-on-sale clause to only encompass conveyances subject to an agreement. Furthermore, section B(13) was a typed additional provision to the contract while section B(6) was a clause set forth in the printed form. If a conflict occurs in the provisions of a contract, I.C. § 29-109 states that the written portion controls over the printed portion. See Werry v. Phillips Petroleum Co., 97 Idaho 130, 540 P.2d 792 (1975). Therefore, because section B(13) is the controlling clause and because it only applies to conveyances subject to an agreement, we hold that even though some due-on-sale clauses may be valid, section B(13) does not apply to the involuntary conveyance here involved. We affirm the judgment of the trial court.
Costs to respondent.
No attorney fees on appeal.
BISTLINE and HUNTLEY, JJ., concur.
SHEPARD, J., concurs in result.
BAKES, Justice, dissenting:
This case ought to be controlled by our decision in Lake v. Equitable Savings & Loan Association, 105 Idaho 923, 674 P.2d 419 (1983). Accordingly, the judgment of the district court should be reversed.
