Where
OriginalTextbox holds the original number:
- Private Sub OriginalTextbox_AfterUpdate()
-
If Not IsNull(Me.OriginalTextbox) Then
-
Me.TextboxA = Me.OriginalTextbox / 2
-
Me.TextboxB = Me.OriginalTextbox / 2
-
Else
-
Me.TextboxA = Null
-
Me.TextboxB = Null
-
End If
-
End Sub
If
TextboxA and
TextboxB are bound to a field in the underlying table, this is all you need. Simply replace the three textbox names with your actual names.
Having said that, calculated fields such as
TextboxA and
TextboxB should never really be stored in the underlying table! They should simply be re-calculated as needed. To do this as you move from record to record,
in addition to the code listed above, you'll need the same code in the
Form_Current event:
- Private Sub Form_Current()
-
If Not IsNull(Me.OriginalTextbox) Then
-
Me.TextboxA = Me.OriginalTextbox / 2
-
Me.TextboxB = Me.OriginalTextbox / 2
-
Else
-
Me.TextboxA = Null
-
Me.TextboxB = Null
-
End If
-
End Sub
If you need to use
TextboxA and
TextboxB in a report, create a calculated field on your report and use the same expressions as above.
Linq
;0)>