Search code examples
vbams-access

Get value of field by calculation based on compression of 2 Combo Box... if used as need to add more formula


I am trying to get the field value by formula by comparing 2 combo boxes. I am getting the 1st part right but the 2nd part.

Private Sub Convert_Rate_Unit_AfterUpdate()
    If [Convert_Rate_Unit] = [Rate_Per_Unit] Then
        [ConvertRate] = [Rate]
        If [Convert_Rate_Unit] <> [Rate_Per_Unit] Then
            [ConvertRate] = [Rate / 1000]
        End If
    End If
End Sub

Solution

  • It is the brackets you've got wrong:

    Private Sub Convert_Rate_Unit_AfterUpdate()
    
        If [Convert_Rate_Unit] = [Rate_Per_Unit] Then
            [ConvertRate] = [Rate]
        Else
            [ConvertRate] = [Rate] / 1000
        End If
    
    End Sub