Results 1 to 16 of 16

Thread: Simple VBA calculation

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Feb 2015
    Posts
    36
    Location

    SOLVED Simple VBA calculation

    Hi all,

    I have a simple math problem.

    I am trying to automatically calculate the value of a couple fields.

    It is a very simple equation:

    txtStockEOS1 = txtStockSOS1.value + txtStockReceive1.value - txtStockLost1.value - txtStockBroken1.value - txtStockWorn1.value

    I.e., 10 = 5+8-1-1-1

    I get a run-time error 13: type mismatch when I enter a value in one of my fields whilst testing. This is my code:


    Private Sub txtStockSOS1_Change()
    Me.txtStockEOS1 = CDbl(txtStockSOS1.Value) + CDbl(txtStockReceive1.Value) - CDbl(txtStockLost1.Value) - CDbl(txtStockBroken1.Value) - CDbl(txtStockWorn1.Value)
    End Sub
    Last edited by onmyway; 02-03-2015 at 07:04 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •