How to save calculated values in MS Access

前端 未结 3 1124
花落未央
花落未央 2021-01-26 22:27

I have a textbox in a form that I created.

I want to add an expression in the textbox\'s Control Source property. I also want to bind the textbox to a field in the tabl

3条回答
  •  臣服心动
    2021-01-26 23:05

    If you have a text box named txtMy_field which is bound to a field named My_field in your form's record source, you could use the form's on current event to load the sum of those other two numbers into txtMy_field.

    If you don't want to over-ride existing values stored in My_field ...

    If IsNull(Me.txtMy_field) = True Then
        Me.txtMy_field = Number1 + Number2
    End If
    

    If you do want to over-ride existing values stored in My_field, eliminate the IsNull() condition.

    Me.txtMy_field = Number1 + Number2
    

    If Number1 and Number2 are from other controls on your form, you could also use their after update events to update txtMy_field value on demand.

    However, I'm unsure how well I understand your question. These are only general suggestions and I hope they point you to something useful. Incidentally, if those two numbers come from two different forms (as in one of your previous questions) and you intend to display and store their sum via a third form, this could be more challenging than it appears from this question.

提交回复
热议问题